1

Topic: How to implement the similar?

Earlier it was not necessary to face let there is any class containing basically any fields (about fields, besides, that they of simple types (well type int, string, etc.) (without methods (the designer is not counted)) it is necessary to write the generator of a considerable quantity of field values of this class. For example something of type of it: class gen <T> {List <T> gen ();} as it is implemented? If it is possible with a simple example.

2

Re: How to implement the similar?

Hello, Kaifa, you wrote:  looked? You define T.Delaesh's type switch which depending on type generates "a considerable quantity of values" this type. Simple types not so much, it is easy to envelop all.

3

Re: How to implement the similar?

Hello, Kaifa, you wrote: K> it was not necessary to face K> let there is any class containing basically any fields (about fields earlier, besides, that they of simple types (well type int, string, etc.) (without methods (the designer is not counted)) K> it is necessary to write the generator of a considerable quantity of field values of this class. For example something of type of it: K> K> class gen <T> K> {K> List <T> gen (); K>} K> K> as it is implemented? If it is possible with a simple example. To create object of a class: var obj = Activator. CreateInstance <T> (); If it is necessary to cause the designer with parameters, that is an appropriate variant of a method. To work with fields it is possible through : foreach (var f in typeof (T).GetFields ())//all fields of class  {object value; if (f. FieldType == typeof (int)) {value = 42;//it is generated any value for int} else if (f. FieldType == typeof (string)) {value = "string42";} ... f. SetValue (obj, value);//we install field value} well or by analogy through GetProperties or more the general GetMembers if are necessary not only fields, but also properties.

4

Re: How to implement the similar?

Hello, Kaifa, you wrote: K> it was not necessary to face K> let there is any class containing basically any fields (about fields earlier, besides, that they of simple types (well type int, string, etc.) (without methods (the designer is not counted)) K> it is necessary to write the generator of a considerable quantity of field values of this class. For example something of type of it: K> K> class gen <T> K> {K> List <T> gen (); K>} K> K> as it is implemented? If it is possible with a simple example.  XML or json and to create the deserializer on the basis of this data? Or   on the same, forgive-hosspadi, T4 engine?

5

Re: How to implement the similar?

MD> Nagenerit XML or json and to create the deserializer on the basis of this data? MD> or   on the same, forgive-hosspadi, T4 engine? I did not understand that you just told

6

Re: How to implement the similar?

Hello, Kaifa, you wrote: K> it was not necessary to face K> let there is any class containing basically any fields (about fields earlier, besides, that they of simple types (well type int, string, etc.) (without methods (the designer is not counted)) K> it is necessary to write the generator of a considerable quantity of field values of this class. For example something of type of it: to Fill fields of objects with any data or garbage? https://github.com/bchavez/Bogus

7

Re: How to implement the similar?

K> it is necessary to write the generator of a considerable quantity of field values of this class. For example something of type of it: If it is necessary on operation (test objects, for example, ), instead of for self-education I would advise on AutoFixture to look. var fixture = new Fixture (); var sut = fixture. Create <MyClass> (); var collection = fixture. CreateMany <MyAnotherClass> ();