List from dynamic Class does not generate Key -
i try generate list<> dynamic class, of 1 person here came little further not need
i need this: imgur.com/oiiyq0f
i have this: imgur.com/9shrhu6
whatever try cant seems right output, not understand difference have , should have (the key name), awesome if kill problem , explain difference code:
foreach (datarow r in _data.rows) { dynamicclass dynamicclass = new dynamicclass(); foreach (string property in properties) { dynamicclass.property[property.tostring()] = _data.rows[i][property].tostring(); } dynamicclasslist.add(dynamicclass); } [debuggertypeproxy(typeof(dynamicclassproxy))] public class dynamicclass { // property class create dynamic properties @ runtime private dynamicproperty _property = new dynamicproperty(); public dynamicproperty property { { return _property; } set { _property = value; } } [debuggerdisplay("{value}", name = "{key,nq}")] private class keyvaluepair { private object key; private object value; public keyvaluepair(keyvaluepair<string, object> kvp) { this.value = kvp.value; this.key = kvp.key; } } private class dynamicclassproxy { private dynamicclass _dynamicclass; public dynamicclassproxy(dynamicclass dynamicclass) { _dynamicclass = dynamicclass; } [debuggerbrowsable(debuggerbrowsablestate.roothidden)] public keyvaluepair[] keys { { return _dynamicclass.property.properties.select(x => new keyvaluepair(x)).toarray(); } } } public class dynamicproperty { //make no 1 can create these objects. internal dynamicproperty() { } // dictionary hold dynamic property values internal dictionary<string, object> properties = new dictionary<string, object>(); // property call dynamic property in our dictionary, or "" if none found. public object this[string name] { { if (properties.containskey(name)) { return properties[name]; } return ""; } set { properties[name] = value; } } } }
Comments
Post a Comment