public static string GetUri(this SourceObject entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (entity is Namespace) { return(GetUri((Namespace)entity)); } if (entity is Block) { return(GetUri((Block)entity)); } if (entity is MetaProperty) { return(GetUri((MetaProperty)entity)); } if (entity is DataType) { return(GetUri((DataType)entity)); } if (entity is Member) { return(GetUri((Member)entity)); } throw new ArgumentException("Unknown entity type: " + entity.GetType().Name); }
private PropertyInfo GetProperty(string propertyName) { if (SourceObject == null) { return(null); } return(SourceObject.GetType().GetProperty(propertyName, Type.EmptyTypes)); }
public void RefreshFromSource() { if (SourceObject != null) { Type type = SourceObject.GetType(); SourceProperty = type.GetProperty(_SourcePropertyName, BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); if (SourceProperty != null) { Value = SourceProperty.GetValue(SourceObject, null); } } }
private IEnumerable <IPropertyGridItem> GetProperties() { var propertyGridItemType = typeof(PropertyGridItem <>); var propertyInfos = SourceObject.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy); foreach (var propertyInfo in propertyInfos) { var browsableAttribute = (BrowsableAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(BrowsableAttribute)); if (browsableAttribute != null && !browsableAttribute.Browsable) { continue; } yield return((IPropertyGridItem)Activator.CreateInstance(propertyGridItemType.MakeGenericType(propertyInfo.PropertyType), new object[] { SourceObject, propertyInfo })); } }
private void ThrowIfPropertyDoesntExistOnSource(string propertyName) { if (SourceObject != null) { if (GetProperty(propertyName) == null) { // Property 'Foreground' doesn't exist on type 'Window' throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Get(SRID.WFI_PropertyDoesntExist), propertyName, SourceObject.GetType().FullName)); } } }
public override string ToString() { var type = SourceObject?.GetType().GetGenericTypeParameterOfCollection() ?? SourceObject?.GetType(); return(Relationship.Name + " <" + (type?.ToString() ?? "unknown") + ">"); }