Dynamic type Object

Source: Internet
Author: User

 public class Ront_examine_view_model:dynamicobject {//Save object dynamically defined property value private dictionary<string, OB        Ject> _values;        Public Ront_examine_view_model () {_values = new dictionary<string, object> (); } public dictionary<string, object> Values {get {return _values            ; }}///<summary>///Get property values//</summary>//<param name= "proper Tyname "></param>///<returns></returns> public Object GetPropertyValue (string prop Ertyname) {if (_values.            ContainsKey (propertyname) = = True) {return _values[propertyname];        } return null; }///<summary>//Set attribute values///</summary>//<param name= "PropertyName" &G t;</param>//<param name= "value" ></param> public void setPropertyValue (String propertyname, Object value) {if (_values.            ContainsKey (propertyname) = = True) {_values[propertyname] = value; } else {_values.            ADD (propertyname, value); }}///<summary>///To implement Dynamic object property member access, to return the value of the specified property///</summary>/// Lt;param name= "Binder" ></param>//<param name= "result" ></param>//&LT;RETURNS&G            t;</returns> public override bool Trygetmember (GetMemberBinder binder, out object result) { result = GetPropertyValue (binder.            Name); return result = = null?        False:true;          }///<summary>///To implement Dynamic object property value settings. </summary>//<param name= "binder" ></param>//<param name= "value" ></pa ram>//<returns></returns> public override bool Trysetmember (SetMemberBinder Binder, Object value) {SETPR Opertyvalue (binder.            Name, value);        return true; }///<summary>///actual code executed when dynamic object dynamic method is called///</summary>//<param name= "bi NDEr "></param>//<param name=" args "></param>//<param name=" Result "></ param>//<returns></returns> public override bool Tryinvokemember (Invokememberbinder BI NDEr, object[] args, out object result) {var thedelegateobj = GetPropertyValue (binder.            Name) as DELEGATEOBJS;                if (thedelegateobj = = NULL | | thedelegateobj.callmethod = = NULL) {result = null;            return false;            } result = Thedelegateobj.callmethod (this, args);        return true; } public override bool Tryinvoke (Invokebinder binder, object[] args, out object result) {return base.        Tryinvoke (binder, args, out result);    }} public delegate object Mydelegates (dynamic Sender, params object[] PMs);        public class Delegateobjs {private Mydelegates _delegate;        Public Mydelegates Callmethod {get {return _delegate;}        } private Delegateobjs (Mydelegates d) {_delegate = D;          }///<summary>//Constructs a delegate object to make it look a bit JavaScript-defined flavor.          </summary>//<param name= "D" ></param>//<returns></returns>        public static Delegateobjs Function (Mydelegates d) {return new delegateobjs (d); }    }

 Dynamic view = new Ront_examine_view_model (); View. Ac_value = Item.                            Ac_value; View. Check_tool = Item.                            Check_tool; View. Check_type = Item.                            Check_type; View. Duty_department = Item.                            Duty_department; View. Fail_desc = Item.                            Fail_desc; View. FEATURES = Item.                            FEATURES; View. Features_level = Item.                            Features_level; View. Fix_num = Item.                            Fix_num;                            View.id = item.id; View. Inspection_level = Item.                            Inspection_level; View. Inspection_result = Item.                            Inspection_result;                            View.is_inspector = Item.is_inspector; View. Isqual = Item.                            isqual; View. Item_name = Item.                            Item_name; View. Item_type = Item.                    Item_type;        View. Offset_value_low = Item.                            Offset_value_low; View. OFFSET_VALUE_UP = Item.                            OFFSET_VALUE_UP; View. Re_value = Item.                            Re_value; View. Reference_value = Item.                            Reference_value; View. Row_index = Item.                            Row_index; View. sample_inspection_id = Item.                            sample_inspection_id; View. SEQ = Item.                            SEQ; View. Standard_value = Item.                            Standard_value; View. state = Item.                            State; View. STATUS = Item.                            STATUS; View. Tech_requirement = Item.                            Tech_requirement; View. UNIT = Item.                            UNIT; View. Roworder = Item.                            Row_index;                                foreach (Var extend in extendcolumns.findall (e = e.detail_id = = item.id)) { View. setPropertyValue (Extend.column_name. Trim (), Extend.                            Column_value); } retobjs.add (view);

  

Dynamic type Object

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.