private static DSPResource CreateResource(DSPMetadata metadata, string entityTypeName, int idValue, KeyValuePair <string, object>[] propertyValues, bool useComplexType) { var entityType = metadata.GetResourceType(entityTypeName); DSPResource entity; if (useComplexType) { entity = new DSPResource(entityType); } else { entity = new DSPResource(entityType, propertyValues); } entity.SetValue("ID", idValue); DSPResource resourceForProperties; if (useComplexType) { string complexTypeName = GetComplexTypeName(entityTypeName); var complexType = metadata.GetResourceType(complexTypeName); resourceForProperties = new DSPResource(complexType, propertyValues); entity.SetValue("ComplexProperty", resourceForProperties); } else { resourceForProperties = entity; } return(entity); }
private static DSPContext GetDefaultData(DSPMetadata metadata) { var peopleType = metadata.GetResourceType("PeopleType"); var officeType = metadata.GetResourceType("OfficeType"); #region Default Data for the Model var context = new DSPContext(); DSPResource people1 = new DSPResource(peopleType); people1.SetValue("ID", 1); people1.SetValue("Name", "Foo"); people1.SetValue("Body", Encoding.UTF8.GetBytes("a byte array")); people1.SetValue("Age", 23); var office = new DSPResource(officeType); office.SetValue("Building", "Building 18"); office.SetValue("OfficeNumber", 100); people1.SetValue("Office", office); var people = context.GetResourceSetEntities("People"); people.Add(people1); #endregion Default Data for the Model return(context); }
/// <summary> /// Creates a datasource from the given metadata. /// </summary> /// <param name="metadata">The metadata against which the datasource is created.</param> /// <returns>DSPContext representing the data source.</returns> private static DSPContext CreateDataSource(DSPMetadata metadata) { DSPContext context = new DSPContext(); ResourceType customerType = metadata.GetResourceType("CustomerEntity"); DSPResource entity1 = new DSPResource(customerType); entity1.SetValue("ID", 1); entity1.SetValue("Name", "Vineet"); DSPResource entity2 = new DSPResource(customerType); entity2.SetValue("ID", 2); entity2.SetValue("Name", "Jimmy"); context.GetResourceSetEntities("CustomerEntities").Add(entity1); context.GetResourceSetEntities("CustomerEntities").Add(entity2); return(context); }