private void LoadDynamicFormMetadataFromAssemblies(Tlahui.Context.WebAPI.WebAPIContext context) { List <Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); foreach (Assembly a in assemblies) { var uidynamics = a.DefinedTypes.Where(type => type.ImplementedInterfaces.Any(inter => inter == typeof(IDynamicUIResource))).ToList(); foreach (TypeInfo tipo in uidynamics) { System.Type t = System.Type.GetType(tipo.AssemblyQualifiedName); System.Attribute[] attrs; //Check localization on type attrs = System.Attribute.GetCustomAttributes(t); foreach (System.Attribute attr in attrs) { if (attr is EntitiesUIMetadata) { EntitiesUIMetadata resource = (EntitiesUIMetadata)attr; context.DynamicFormMetadataProperties.AddOrUpdate(x => new { x.ResourceId }, new DynamicFormMetadata() { ResourceId = t.FullName, ResourceGroupId = t.FullName, ShortId = t.FullName.Split('.').ToList().Last(), APIDictionaryEndpoint = resource.APIDictionaryEndpoint, DictionaryKey = resource.DictionaryKey, DictionaryValue = resource.DictionaryValue, DictionaryValueIndex = resource.DictionaryValueIndex, BoolDisplayType = resource.BoolDisplayType, ActionAvailable = resource.ActionAvailable, AddActionAvailable = resource.AddActionAvailable, Col = resource.Col, ControlType = resource.ControlType, DataSourceType = resource.DataSourceType, DefaultValue = resource.DefaultValue, DeleteActionAvailable = resource.DeleteActionAvailable, Height = resource.Height, Row = resource.Row, Type = resource.Type, UpdateActionAvailable = resource.UpdateActionAvailable, Width = resource.Width, MaxLen = resource.MaxLen, MaxValue = resource.MaxValue, MinLen = resource.MinLen, MinValue = resource.MinValue, Required = resource.Required }); } } //Check localization within interfaces var interfaces = t.GetInterfaces().ToList(); foreach (Type ifc in interfaces) { var iprops = ifc.GetProperties().ToList(); foreach (PropertyInfo pi in iprops) { attrs = System.Attribute.GetCustomAttributes(pi); foreach (System.Attribute attr in attrs) { if (attr is EntitiesUIMetadata) { EntitiesUIMetadata resource = (EntitiesUIMetadata)attr; context.DynamicFormMetadataProperties.AddOrUpdate(x => new { x.ResourceId }, new DynamicFormMetadata() { ResourceId = t.FullName + "." + pi.Name, ResourceGroupId = t.FullName, ShortId = pi.Name, APIDictionaryEndpoint = resource.APIDictionaryEndpoint, DictionaryKey = resource.DictionaryKey, DictionaryValue = resource.DictionaryValue, DictionaryValueIndex = resource.DictionaryValueIndex, BoolDisplayType = resource.BoolDisplayType, ActionAvailable = resource.ActionAvailable, AddActionAvailable = resource.AddActionAvailable, Col = resource.Col, ControlType = resource.ControlType, DataSourceType = resource.DataSourceType, DefaultValue = resource.DefaultValue, DeleteActionAvailable = resource.DeleteActionAvailable, Height = resource.Height, Row = resource.Row, Type = resource.Type, UpdateActionAvailable = resource.UpdateActionAvailable, Width = resource.Width, MaxLen = resource.MaxLen, MaxValue = resource.MaxValue, MinLen = resource.MinLen, MinValue = resource.MinValue, Required = resource.Required }); } } } } //Check localization within properties var props = t.GetProperties().ToList(); foreach (PropertyInfo pi in props) { attrs = System.Attribute.GetCustomAttributes(pi); foreach (System.Attribute attr in attrs) { if (attr is EntitiesUIMetadata) { EntitiesUIMetadata resource = (EntitiesUIMetadata)attr; context.DynamicFormMetadataProperties.AddOrUpdate(x => new { x.ResourceId }, new DynamicFormMetadata() { ResourceId = t.FullName + "." + pi.Name, ResourceGroupId = t.FullName, ShortId = pi.Name, APIDictionaryEndpoint = resource.APIDictionaryEndpoint, DictionaryKey = resource.DictionaryKey, DictionaryValue = resource.DictionaryValue, DictionaryValueIndex = resource.DictionaryValueIndex, BoolDisplayType = resource.BoolDisplayType, ActionAvailable = resource.ActionAvailable, AddActionAvailable = resource.AddActionAvailable, Col = resource.Col, ControlType = resource.ControlType, DataSourceType = resource.DataSourceType, DefaultValue = resource.DefaultValue, DeleteActionAvailable = resource.DeleteActionAvailable, Height = resource.Height, Row = resource.Row, Type = resource.Type, UpdateActionAvailable = resource.UpdateActionAvailable, Width = resource.Width, MaxLen = resource.MaxLen, MaxValue = resource.MaxValue, MinLen = resource.MinLen, MinValue = resource.MinValue, Required = resource.Required }); } } } } } }
private void LoadDynamicTableMetadataFromAssemblies(Tlahui.Context.WebAPI.WebAPIContext context) { List <Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); foreach (Assembly a in assemblies) { var uidynamics = a.DefinedTypes.Where(type => type.ImplementedInterfaces.Any(inter => inter == typeof(IDynamicUIResource))).ToList(); foreach (TypeInfo tipo in uidynamics) { System.Type t = System.Type.GetType(tipo.AssemblyQualifiedName); System.Attribute[] attrs; try { //Intenta extraer el query de la clase existe la constante QUERY string query = (string)t.GetField("QUERY").GetValue(null); context.EntityQueries.AddOrUpdate(x => x.ResourceId, new EntityQuery() { Query = query, ResourceId = t.FullName }); } catch (Exception ex) { } //Check localization on type attrs = System.Attribute.GetCustomAttributes(t); foreach (System.Attribute attr in attrs) { if (attr is EntitiesUIMetadata) { EntitiesUIMetadata resource = (EntitiesUIMetadata)attr; context.DynamicTableMetadataProperties.AddOrUpdate(x => new { x.ResourceId }, new DynamicTableMetadata() { DisplayByDefault = resource.DisplayByDefault, AlwaysHidden = resource.AlwaysHidden, DisplayIndex = resource.DisplayIndex, IsID = resource.IsID, OutpuFormat = resource.OutpuFormat, Searchable = resource.Searchable, Type = resource.Type.GetHashCode(), ResourceId = t.FullName, ResourceGroupId = t.FullName, ShortId = t.FullName.Split('.').ToList().Last(), APIDictionaryEndpoint = resource.APIDictionaryEndpoint, DeafultSort = resource.DefaultSort, DictionaryKey = resource.DictionaryKey, DictionaryValue = resource.DictionaryValue, DictionaryValueIndex = resource.DictionaryValueIndex, BoolDisplayType = resource.BoolDisplayType, MarkDeletedField = resource.MarkDeletedField }); } } //Check localization within interfaces var interfaces = t.GetInterfaces().ToList(); foreach (Type ifc in interfaces) { var iprops = ifc.GetProperties().ToList(); foreach (PropertyInfo pi in iprops) { attrs = System.Attribute.GetCustomAttributes(pi); foreach (System.Attribute attr in attrs) { if (attr is EntitiesUIMetadata) { EntitiesUIMetadata resource = (EntitiesUIMetadata)attr; context.DynamicTableMetadataProperties.AddOrUpdate(x => new { x.ResourceId }, new DynamicTableMetadata() { DisplayByDefault = resource.DisplayByDefault, AlwaysHidden = resource.AlwaysHidden, DisplayIndex = resource.DisplayIndex, IsID = resource.IsID, OutpuFormat = resource.OutpuFormat, Searchable = resource.Searchable, Type = resource.Type.GetHashCode(), ResourceId = t.FullName + "." + pi.Name, ResourceGroupId = t.FullName, ShortId = pi.Name, APIDictionaryEndpoint = resource.APIDictionaryEndpoint, DeafultSort = resource.DefaultSort, DictionaryKey = resource.DictionaryKey, DictionaryValue = resource.DictionaryValue, DictionaryValueIndex = resource.DictionaryValueIndex, BoolDisplayType = resource.BoolDisplayType, MarkDeletedField = resource.MarkDeletedField }); } } } } //Check localization within properties var props = t.GetProperties().ToList(); foreach (PropertyInfo pi in props) { attrs = System.Attribute.GetCustomAttributes(pi); foreach (System.Attribute attr in attrs) { if (attr is EntitiesUIMetadata) { EntitiesUIMetadata resource = (EntitiesUIMetadata)attr; context.DynamicTableMetadataProperties.AddOrUpdate(x => new { x.ResourceId }, new DynamicTableMetadata() { DisplayByDefault = resource.DisplayByDefault, AlwaysHidden = resource.AlwaysHidden, DisplayIndex = resource.DisplayIndex, IsID = resource.IsID, OutpuFormat = resource.OutpuFormat, Searchable = resource.Searchable, Type = resource.Type.GetHashCode(), ResourceId = t.FullName + "." + pi.Name, ResourceGroupId = t.FullName, ShortId = pi.Name, APIDictionaryEndpoint = resource.APIDictionaryEndpoint, DeafultSort = resource.DefaultSort, DictionaryKey = resource.DictionaryKey, DictionaryValue = resource.DictionaryValue, DictionaryValueIndex = resource.DictionaryValueIndex, BoolDisplayType = resource.BoolDisplayType, MarkDeletedField = resource.MarkDeletedField }); } } } } } }