private ReferenceTypeModel ConvertReferenceProperty(PropertyInfo property, IDictionary <string, List <Type> > overrides) { var referenceAttr = property.GetCustomAttribute <ResourceReferenceAttribute>(); var displayName = property.GetDisplayName(); // Create reference model from property information and optional attribute var referenceModel = new ReferenceTypeModel { Name = property.Name, DisplayName = !string.IsNullOrEmpty(displayName) ? displayName : property.Name, Description = property.GetDescription(), Role = referenceAttr.Role, RelationType = referenceAttr.RelationType, IsRequired = referenceAttr.IsRequired, IsCollection = typeof(IEnumerable <IResource>).IsAssignableFrom(property.PropertyType) }; // Get type constraints Type targetType = property.PropertyType; if (referenceModel.IsCollection) { targetType = EntryConvert.ElementType(targetType); } var typeConstraints = MergeTypeConstraints(property, targetType, overrides); referenceModel.SupportedTypes = TypeController.SupportedTypes(typeConstraints).Select(t => t.Name).ToArray(); return(referenceModel); }
private static void RenameInterfacePropertyInBaseClasses(InterfaceModel interfaceModel, ReferenceTypeModel implementationClass, PropertyModel interfaceProperty, string newName) { foreach (var interfaceModelImplementationClass in interfaceModel.AllDerivedReferenceTypes().Where(c => c != implementationClass)) { foreach (var propertyModel in interfaceModelImplementationClass.Properties.Where(p => p.Name == interfaceProperty.Name)) { propertyModel.Name = newName; } } }
public ReferenceTypeViewModel(ResourceTypeViewModel resourceType, ReferenceTypeModel model) { ResourceType = resourceType; Model = model; }