ObjectGenerator Class

Namespace:
Weavy.Web.Areas.Docs.Samples
Assembly:
Weavy.Web.dll

This class will create an object of a given type and populate it with sample data.

public class ObjectGenerator
Inheritance:
System.Object → ObjectGenerator

Constructors

ObjectGenerator()

Methods

GenerateObjectWithSample(Type, IDictionary) Generates an object for a given type. The type needs to be public, have a public default constructor and settable public properties/fields. Currently it supports the following types: Simple types: System.Int32, System.String, System.Enum, System.DateTime, System.Uri, etc. Complex types: POCO types. Nullables: System.Nullable%601. Arrays: arrays of simple types or complex types. Key value pairs: System.Collections.Generic.KeyValuePair%602 Tuples: System.Tuple%601, System.Tuple%602, etc Dictionaries: System.Collections.Generic.IDictionary%602 or anything deriving from System.Collections.Generic.IDictionary%602. Collections: System.Collections.Generic.IList%601, System.Collections.Generic.IEnumerable%601, System.Collections.Generic.ICollection%601, System.Collections.IList, System.Collections.IEnumerable, System.Collections.ICollection or anything deriving from System.Collections.Generic.ICollection%601 or System.Collections.IList. Queryables: System.Linq.IQueryable, System.Linq.IQueryable%601.

Extension Methods

Serialize(object) Serializes an object, or graph of connected objects, to a byte array.
SerializeToJson(object, Formatting?, JsonSerializerSettings) Serializes an object, or graph of connected objects, to a json string.
IsValid(object) Determines whether the specified object is valid by evaluating each ValidationAttribute instance that is attached to the object type.