|
I didn't really mean use generics per-se... I meant just to keep the list simple. I define a basic class that allows you define a Key and Value pair of Key = int, Value = object, wrap that is a small class, provide some accessors and generic initialize, then build a list of those:
List<keyvaluepair> kvp = new List<keyvalurpair>
|
|
|
|
|
Ah, ok, generic as in the normal meaning, not the specific programming meaning (i.e. List<KeyValuePair> or List(Of KeyValuePair)), right, sorry - misunderstood you.
In that case, if both ends are WCF, you should be able to cast the Value property objects when they come out the other end to their specific types (assuming you have access to them, i.e. you've included the assembly on the other end). If not I believe you would have to do some funky deserialisation code and manipulation of raw XML, yuck!
I would stick with the D.A.D.S. principle when talking about objects going over the wire:
[DataContract]
public class KeyValuePair
{
[DataMember]
public string Key { get; set; }
[DataMember]
public string Value { get; set; }
}
I agree with Mark, though - why not use WCF? You get all the data types on the receiving end as "real" objects, no loss of Intellisense. Plus, it feels safer
As for your original question/situation, that is a tough one - I'd need to think that one through for a while. I like to use role-play (just leave it ) Walk yourself through the maintenance cycle with a pencil and paper, "you rolled a 5, new HW support required" or "you rolled a 2, implementation of HW type X changes" (no need for a die, that was purely for example). I find working through these situations helps me choose the easier path.
Don't really know if that's what you're looking for... I have emptystomachitis, off to lunch!
|
|
|
|
|
I still think my way of doing it is easier and much less maintenance intensive.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
hi,
i am doing one task in my project.i need to update the holidays in the frontend(ASP.NET).but when i am entering the data it is not getting saved and displaying data as "holiday id cannot allow null values".
i checked in the backend there is no problem in that it is displaying correctly.
only problem is front end.
In the holiday id identity specifications i incremented the properties.eventhough error is coming.
insert into HolidayList(Holiday,Date,Day)
values
(@Holiday,@Date,@Day);
select HolidayId = SCOPE_IDENTITY();
the query used in the sqlserver.in this we are not declaring the holidayid but when we are executing it automatically gets incremented.suppose there are 6 values in table if we enter the next value it automatically displays as 7 value and getting exeuted.
but when coming to the front end it is not saving the data.when we are clicking on the save the page is getting refreshed.
please give me the solution.it is very urgent for me.
thanks
Amala
modified on Tuesday, December 28, 2010 10:11 AM
|
|
|
|
|
You need to post some code here. Until then, it is virtually impossible to figure out the exact problem.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
mandarapuamala wrote: the query used in the sqlserver
And how does the table-definition look? What columns and datatypes does it have?
mandarapuamala wrote: "holiday id cannot allow null values".
i checked in the backend there is no problem in that it is displaying correctly.
Any triggers that are defined on the table?
mandarapuamala wrote: but when coming to the front end it is not saving the data.when we are clicking on the save the page is getting refreshed.
Are you doing an insert or an update at that point?
mandarapuamala wrote: please give me the solution.it is very urgent for me.
This is a free site and questions are answered by volunteers like you, in their spare time. Demanding them to hurry would be inappropriate.
You could also plough through the SCOPE_IDENTITY [^]-documentation on MSDN
I are Troll
|
|
|
|
|
I would suggest to use relevant title so that other people can benefit it
|
|
|
|
|
"Callback" is the delegate. I have a calculated string which give the function name and I want to pass this string to delegate. How can I achive this. Please advice
String FunctionName ="Myfunction"
String FunctionID="5679"
FunctionName = FunctionName + "_" +FunctionID
cbk->m_pCallBack = gcnew Callback(this, FunctionName);
Please advice
|
|
|
|
|
What you ask is tricky, tedious and ugly, and I would suggest you to find a better approach. That said, I think I can give you some clues for what you are asking for, though I have not tested it:
Since you have the function name, you might use reflection to get its MethodInfo object. The MethodInfo has a property called MethodHandle, which returns a RuntimeMethodHandle object. This object can give you an IntPtr function pointer just invoking its GetFunctionPointer method, and you can convert this IntPtr function pointer to a delegate using Marshal.GetDelegateForFunctionPointer. As I said before, tricky, tedious and ugly. If you explain us a little more of what you want to do, maybe we can help you to find a better solution.
|
|
|
|
|
//function names string array
static array<String^>^ FunctionNames = gcnew array<String^> {
"&MyClass::Function_1",
"&MyClass::Function_2",
"&MyClass::Function_3",
"&MyClass::Function_4",
"&MyClass::Function_5",
.....
"&MyClass::Function_40"
};
array<FLE^> ^ entry = gcnew array<FLE^>(40);
for each (String^ FuncName in FunctionNames)
{
String FunctionName ="Myfunction"
String FunctionID="Count.ToString();
FunctionName = FunctionName + "_" +FunctionID="
cbk->m_pCallBack = gcnew Callback(this, FunctionName);
m_FL->Add(FunctionID, entry[iCount]);
iCount++;
}
|
|
|
|
|
I see you are storing the function names into a string array. Why don't you use a Dictionary<string, callback=""> to store the pair? The string representing the function name would be the key, and the corresponding delegate for that function would be the value. It would be much easier than what you pretend to do.
|
|
|
|
|
Some more info on what you are trying to achieve would be helpfull.
|
|
|
|
|
I am using ASP.Net 2008, and I want to connect Database SQL Server 2000 But when i add new database connection "Network related - Or Instance specific error occurred while establishing connection to the SQL Server." error comes. and when I connect to SQL Server 2005 it works properly. Anyone know the solution.
thanks
|
|
|
|
|
if you can connect with odbcad32.exe, then go to connectionstrings.com as your connection string is not correct.
|
|
|
|
|
Dear All,
I have the follow data in my Dataset1.Table(0)
col1 Col2 Col3 Col4 Col5 Qty
SS 111 SIN C 20 114
SS 111 SIN C 40 28
SS 111 SIN S 20 165
SS 111 SIN S 40 189
I want to SUM(Qty) those are same color
The result will like below
SSUM 111 SGSIN 20 279 (row1 + row3)
SSUM 111 SGSIN 40 217 (row2 + row4)
I don’t want to loop and sum row by row. Is there any DataTable Method to get my result?
If I use like this how will be my result?
Dataset1.Table(0).Compute("Sum(Qty)","Group by Col1,Col2,Col3,Col5")
Please, any suggestion for the best way.
Thanks and Best Regards
|
|
|
|
|
|
|
Hello,
Today I've noticed something interesting to me and I'd like to understand.
Let's say I have a function like this one:
public enum SomeEnum
{
Value1 = 0,
Value2 = 1
}
public void DoSomething(SomeEnum theEnum)
{
if(theEnum == SomeEnum.Value1)
return;
}
When I build the project which is a ClassLibrary in Debug mode the compiler translates that to:
public void DoSomething(SomeEnum theEnum)
{
if(theEnum == 0)
{
return;
}
}
But when I build the same project in Release mode the result is:
public void DoSomething(SomeEnum theEnum)
{
if(theEnum == null)
{
return;
}
}
This seems to happen only when the Enum has two values.
Anyone?
Thanks.
|
|
|
|
|
_Zorro_ wrote: the compiler translates that to...
I doubt that very much. How do you make such observation?
if reflector is involved (which version?), have a look at the IL code itself (not the decompiled "source" code), and show it here.
|
|
|
|
|
Sorry for the delay, didn't checked my mail in a while
Ok, I had to be drunk that day, even if i'm pretty sure of what I saw I am unable to reproduce that issue today... It's been an hour I'm trying with no success so I'll leave it there.
I shouldn't have deleted my test project...
Thank's to you both for your answers and happy new year!
|
|
|
|
|
Also doubt that, especially since the optimizing compiler is likely to change the test to !theEnum instead of using the == operator.
|
|
|
|
|
|
Hi guys, now am in a remoting project. I need to transfer a TreeNode control using remoting.
Is it possible in remoting i don't know, if any one know explain me
Thanks in advance
ganesh_IT
|
|
|
|
|
I have this C# application that has been compiled as "AnyCPU". No problem running it on my 32bit machines. Nor my 64-bit machines. But a friend of mine is having a strange issue where the app seem to be forced into 32-bit-mode (TaskManager marks it with "(*32)"). This in turn causes a "BadImageFormatException" when a pice of code relying on a external DLL is loaded (during install the correct .dll file is copied based on wether Windows is 64 or 32 bit). CorFlags tell me that the application isnt force to 32bit, so why the heck is it running as 32 bit on a 64 bit OS?! (and yes, the .Net framework is installed for both 64 and 32 bit on the machine in question).
|
|
|
|
|
Because AnyCPU will compile to target the lowest common denominator of supported hardware which is 32 bit.
I wasn't, now I am, then I won't be anymore.
|
|
|
|