Click here to Skip to main content
15,895,799 members
Home / Discussions / C#
   

C#

 
Questiondatagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
shrikanth_BG7-Mar-14 0:48
shrikanth_BG7-Mar-14 0:48 
AnswerRe: datagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
Eddy Vluggen7-Mar-14 7:15
professionalEddy Vluggen7-Mar-14 7:15 
GeneralRe: datagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
shrikanth_BG9-Mar-14 20:06
shrikanth_BG9-Mar-14 20:06 
Questionerror connection c# with oracle 11xe Pin
honar.cs6-Mar-14 21:28
honar.cs6-Mar-14 21:28 
AnswerRe: error connection c# with oracle 11xe Pin
Richard MacCutchan6-Mar-14 22:00
mveRichard MacCutchan6-Mar-14 22:00 
AnswerRe: error connection c# with oracle 11xe Pin
Pete O'Hanlon6-Mar-14 22:00
mvePete O'Hanlon6-Mar-14 22:00 
GeneralRe: error connection c# with oracle 11xe Pin
honar.cs7-Mar-14 1:14
honar.cs7-Mar-14 1:14 
QuestionExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff6-Mar-14 15:48
professionalBillWoodruff6-Mar-14 15:48 
I am doing some exploration ... out of curiosity ... of the 'ExpandoObject in System.Dynamic; so far, I've been able to write a serialize/deserialize to XML function using DataContract, written a method to recursively print to Console all the name/value/Type of the members of a "nested" ExpandoObject.

As you may know, you can add executable code to an ExpandoObject as illustrated in this example:
C#
// requires: using System.Dynamic

dynamic TheExpando = new ExpandoObject();

// add a new virtual property
TheExpando.NewProperty = "some new stuff";

// Expando within Expando
TheExpando.NewBagOfProperties = new ExpandoObject();

TheExpando.NewBagOfProperties.DriversLicense = "A873T23L";
TheExpando.NewBagOfProperties.SocialSecurityNumber = "958-349-3988";

TheExpando.SomeInteger = 100;
TheExpando.AnotherInteger = 200;

// create a block of executable code
Action aMethod = new Action(() =>
{
    MessageBox.Show((test1.TheExpando.SomeInteger + test1.TheExpando.AnotherInteger).ToString());
    test1.TheExpando.SomeInteger += 1000;
});

// add the code to the Expando
test1.TheExpando.AMethod = aMethod;
And, yes, if you then called TheExpando.AMethod(); you would execute the anonymous method, bring-up a MessageBox, and increment the value of TheExpando.SomeInteger.

Note that I assume the negative hypothesis here: I don't think anonymous methods can be serialized ... not without some kind of very complex code that uses Reflection and yogic contortions. This is a tantalizing post on SO, however: [^].

So far, my research indicates that an Action like 'aMethod in the above code cannot be serialized with DataContract, even though this declaration of 'KnownTypes is legal in setting up a DataContract:
C#
// requires: using System.Dynamic
// requires: using System.Runtime.Serialization;
[KnownType(typeof(System.Delegate))]
[KnownType(typeof(System.Action))]
[KnownType(typeof(System.Dynamic.ExpandoObject))]
[DataContract]
public class SomeClassThatIncluesAnExpando
{
    [DataMember]
    public dynamic TheExpando { set; get; }

    // yada yada yada ... more stuff
}
It appears (from my reading on this issue, so far) that you can use a JSON serializer to write an anonymous Type, or Event declaration, to XML.

I have yet to evaluate the 'DataContractResolver facility which might (?) be useful: [^]. I am currently studying this article on serialization of anonymous Types: [^].

I'd appreciate hearing your thoughts on this. Is there any form of Delegate that can be serialized using DataContract ?

fyi: resources

1. ExpandoObject: Use of .NET's Expando object (FrameWork 4.0) in the Dynamic Language Runtime (DLR): [^], [^].

Anoop Madhusudanan has an outstanding article on programming with DLR, using Expando and DynamicObject, and his own very interesting "Elastic Object: [^]; also, see Anoop's blog: [^].
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet


modified 7-Mar-14 1:11am.

AnswerRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen6-Mar-14 22:20
professionalEddy Vluggen6-Mar-14 22:20 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff7-Mar-14 1:39
professionalBillWoodruff7-Mar-14 1:39 
AnswerRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen7-Mar-14 6:49
professionalEddy Vluggen7-Mar-14 6:49 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff7-Mar-14 14:11
professionalBillWoodruff7-Mar-14 14:11 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen7-Mar-14 23:26
professionalEddy Vluggen7-Mar-14 23:26 
QuestionSystem.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 5:34
computerpublic6-Mar-14 5:34 
AnswerRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Andrew x646-Mar-14 5:42
professionalRichard Andrew x646-Mar-14 5:42 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 5:48
computerpublic6-Mar-14 5:48 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Andrew x646-Mar-14 5:50
professionalRichard Andrew x646-Mar-14 5:50 
AnswerRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Deeming6-Mar-14 5:50
mveRichard Deeming6-Mar-14 5:50 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 6:13
computerpublic6-Mar-14 6:13 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Deeming6-Mar-14 6:47
mveRichard Deeming6-Mar-14 6:47 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 7:44
computerpublic6-Mar-14 7:44 
AnswerRe: System.ArgumentOutOfRangeException: Index was out of range Pin
BobJanova6-Mar-14 7:04
BobJanova6-Mar-14 7:04 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 7:47
computerpublic6-Mar-14 7:47 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
computerpublic6-Mar-14 7:49
computerpublic6-Mar-14 7:49 
GeneralRe: System.ArgumentOutOfRangeException: Index was out of range Pin
Richard Deeming6-Mar-14 8:06
mveRichard Deeming6-Mar-14 8:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.