public esColumnMetadataCollection GetColumns(esEntityCollectionBase collection) { collection.EnableHierarchicalBinding = false; PropertyDescriptorCollection props = null; try { MethodInfo GetEntity = collection.GetType().GetMethod("CreateEntity", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); esEntity entity = GetEntity.Invoke(collection, null) as esEntity; MethodInfo GetProperties = collection.GetType().GetMethod("GetProperties", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); props = GetProperties.Invoke(collection, new object[] { entity }) as PropertyDescriptorCollection; } catch { } MethodInfo get_Meta = collection.GetType().GetMethod("get_Meta", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); IMetadata meta = get_Meta.Invoke(collection, null) as IMetadata; esColumnMetadataCollection esColumns = meta.Columns; esColumnMetadataCollection esCollection = new esColumnMetadataCollection(); try { foreach (esColumnMetadata col in esColumns) { esCollection.Add(col); } } catch { } try { if (props != null) { esExtendedPropertyAttribute att = new esExtendedPropertyAttribute(); foreach (PropertyDescriptor prop in props) { if (esColumns.FindByPropertyName(prop.Name) == null) { if (prop.Attributes.Contains(att)) { esColumnMetadata col = new esColumnMetadata(prop.Name, 1000, prop.PropertyType); col.PropertyName = prop.Name; esCollection.Add(col); } } } } } catch { } return(esCollection); }
public esColumnMetadataCollection GetColumns(esEntityCollectionBase collection) { collection.EnableHierarchicalBinding = false; PropertyDescriptorCollection props = null; try { MethodInfo GetEntity = collection.GetType().GetMethod("CreateEntity", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); esEntity entity = GetEntity.Invoke(collection, null) as esEntity; MethodInfo GetProperties = collection.GetType().GetMethod("GetProperties", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); props = GetProperties.Invoke(collection, new object[] { entity }) as PropertyDescriptorCollection; } catch { } MethodInfo get_Meta = collection.GetType().GetMethod("get_Meta", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); IMetadata meta = get_Meta.Invoke(collection, null) as IMetadata; esColumnMetadataCollection esColumns = meta.Columns; esColumnMetadataCollection esCollection = new esColumnMetadataCollection(); try { foreach (esColumnMetadata col in esColumns) { esCollection.Add(col); } } catch { } try { if (props != null) { esExtendedPropertyAttribute att = new esExtendedPropertyAttribute(); foreach (PropertyDescriptor prop in props) { if (esColumns.FindByPropertyName(prop.Name) == null) { if (prop.Attributes.Contains(att)) { esColumnMetadata col = new esColumnMetadata(prop.Name, 1000, prop.PropertyType); col.PropertyName = prop.Name; esCollection.Add(col); } } } } } catch { } return esCollection; }