public IdmCodeGenerator(Schema schemaObject, List<string> objectTypeNames = null, string json = null) { _schemaObject = schemaObject; _objectTypeNames = objectTypeNames; // TODO later 001: eliminate dependency on system environment variables _customSchemaJson = Environment.GetEnvironmentVariable("CUSTOM_ATTR_TO_OBJ_MAPPINGS"); if (!string.IsNullOrWhiteSpace(json)) _referenceMap = JsonConvert.DeserializeObject<List<ReferenceToObjectTypeMap>>(json); }
private async Task<Schema> BuildSchemaObject(string objectType) { var criteria = new SearchCriteria(String.Format("/ObjectTypeDescription[Name='{0}']", objectType)) { Selection = new List<string> { "DisplayName", "CreatedTime", "Creator", "Description", "Name", "ObjectID", "ObjectType", "ResourceTime", "UsageKeyword" } }; IEnumerable<IdmResource> resources = await SearchAsync(criteria); var result = new Schema(resources.FirstOrDefault()); return result; }
public static void GenerateModelAndTests(Schema objectTypeDescription) { var objTypeNames = (from o in _objectTypes select o.GetAttrValue("Name")).ToList(); IdmCodeGenerator generator = new IdmCodeGenerator(objectTypeDescription, objTypeNames, _json); Tuple<string, string> classAndTests = generator.Generate(); var classFile = $@"{TargetDirectoryPath}{objectTypeDescription.Name}.cs"; File.WriteAllText(classFile, classAndTests.Item1); var testsFile = $@"{TargetDirectoryPath}Tests\{objectTypeDescription.Name}Tests.cs"; File.WriteAllText(testsFile, classAndTests.Item2); }
private async Task AddBindingDescriptions(Schema result) { var bindingCriteria = new SearchCriteria(String.Format("/BindingDescription[BoundObjectType='{0}']", result.ObjectID)) { Selection = new List<string> { "DisplayName", "CreatedTime", "Creator", "Description", "Name", "ObjectID", "ObjectType", "ResourceTime", "UsageKeyword", "BoundObjectType", "BoundAttributeType", "Required" } }; IEnumerable<IdmResource> bindingResources = await SearchAsync(bindingCriteria); foreach (var bindingResource in bindingResources) { var binding = new BindingDescription(bindingResource); var attrTypeResource = await GetAsync(binding.BoundAttributeType.ObjectID, new List<string> { "DisplayName", "CreatedTime", "Creator", "Description", "Name", "ObjectID", "ObjectType", "ResourceTime", "UsageKeyword", "DataType", "Multivalued" } ); var attrType = new AttributeTypeDescription(attrTypeResource); binding.BoundAttributeType = attrType; result.BindingDescriptions.Add(binding); } }