Com. qsoft. commons. beanutils source code (. net org. apache. commons. beanutils)
Click to browse this file
Similar to the Apache open-source project org. apache. commons. beanutils (java. net version, which implements some simplified operations on the object class (such as copying the object class, Dynamic assignment, value), provides dynamic entity types, dynamic entity classes, and dynamic attributes.
The next step is to encapsulate dynamic entity classes of some complex objects (such as DataReader and DataTable ). It implements conversion operations with dynamic object classes and custom static object classes (this is not supported by org. apache. commons. beanutils ).
Click to download source code
Test code:
Using system;
Using system. Collections. Generic;
Using system. text;
Using COM. qsoft. commons. beanutils;
Using system. Data;
Namespace test_beanutils
...{
Class Program
...{
Static void main (string [] ARGs)
...{
Testclone ();
Testdynabean ();
Testdatarow2bean ();
Console. readkey ();
}
Private Static void testdatarow2bean ()
...{
Console. writeline ("test dynamic datatableutil :");
Datatable dt = new datatable ();
DT. Columns. Add ("ID", typeof (INT ));
DT. Columns. Add ("name", typeof (string ));
Datarow ROW = DT. newrow ();
Row [& quot; Id & quot;] = 100;
Row ["name"] = "kimm King ";
Object OBJ = datatableutil. datarow2bean (row, typeof (mybean ));
Console. writeline (OBJ );
Console. writeline ();
}
Private Static void testdynabean ()
...{
Console. WriteLine ("test dynamic Bean :");
DynaProperty [] property = ...{
New DynaProperty ("id", typeof (string )),
New DynaProperty ("name", typeof (string )),
New dynaproperty ("email", typeof (string ))
};
Basicdynaclass clazz = new basicdynaclass ("Bean", null, property );
Basicdynabean bean = new basicdynabean (clazz );
// Bean. Set ("QQ", "100 ");
Bean. Set ("ID", "100 ");
Bean. set ("name", "Kimm King ");
Bean. set ("email", "KimmKing@163.com ");
Console. WriteLine (bean );
Console. WriteLine ();
}
Private static void testclone ()
...{
Console. WriteLine ("test Bean clone :");
MyBean mb1 = new MyBean ();
MB 1.id = 100;
Mb1.name = "Kimm King ";
MyBean mb2 = (MyBean) BeanUtils. cloneBean (mb1 );
Console. WriteLine (mb2 );
Console. WriteLine ();
}
}
Public class MyBean
...{
Private int _ id;
Public int ID
...{
Get... {return _ id ;}
Set... {_ id = value ;}
}
Private string _ name;
Public string name
...{
Get... {return _ name ;}
Set... {_ name = value ;}
}
Public override string ToString ()
...{
Return "MyBean [id =" + _ id. ToString () + ", name =" + _ name + "]";
}
}
}
1. Commitment: first, give you a bright future description. It is generally verbal. Draw a pie for you.
2. blur the power and responsibility of the term: you will not tell you about any possible problems in the next step, so that you are not sure whether there is a problem.
3. Work: any attempt to sign an agreement or (no agreement or special job type) without a deposit is a typical characteristic of scammers.
4. Contract: seriously unfair or directly illegal. The right contract should have clear rights and responsibilities. Both parties have clear powers and responsibilities, and are equal and fair without ambiguity. Contracts that are heavily biased towards one party cannot be signed. Each clause is detailed. Do not compromise on any of the issues that may arise in the future. It is illegal to take a non-existent group as the party to the contract.
5. Payment: based on experience, any amount of time (for example, one month) after the work is completed is a liar. A legal company or organization cannot afford to pay for one thing. In a formal procedure, the company generally pays the balance when the deposit is completed. The deposit is not prepaid only when the two parties have full trust in each other. Otherwise, you may be cheated or have a dispute.
6. Evidence: during the entire process, do not use verbal contact for anything involving cooperation. It is best to use email, at least vmsn, and so on, to keep the evidence. In case of a dispute, this can be a decisive thing. The other party verbally gives you an additional task or a promise, telling him to send it to you again in email.
7. ID documents: Check the ID documents of the other party and check the license for the group. The network is virtual. We are in the bright corner, and scammers are in the dark. You must know who the other party is to reduce risks.