// Returns properties that don't yet have corresponding XamlMembers internal IList <PropertyInfo> LookupRemainingProperties() { Debug.Assert(UnderlyingType != null, "Caller should check for UnderlyingType == null"); Debug.Assert(_nonAttachableMemberCache != null, "Members property should have been invoked before this"); PropertyInfo[] propList = UnderlyingType.GetProperties(AllProperties_BF); return(FilterProperties(propList, null, false)); }
IEnumerable <XamlMember> DoLookupAllMembers() { // This is a hack that is likely required due to internal implementation difference in System.Uri. Our Uri has two readonly collection properties if (this == XamlLanguage.Uri) { yield break; } var bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; foreach (var pi in UnderlyingType.GetProperties(bf)) { if (pi.Name.Contains(".")) // exclude explicit interface implementations. { continue; } if (pi.CanRead && (pi.CanWrite || IsCollectionType(pi.PropertyType) || typeof(IXmlSerializable).IsAssignableFrom(pi.PropertyType)) && pi.GetIndexParameters().Length == 0) { yield return(new XamlMember(pi, SchemaContext)); } } foreach (var ei in UnderlyingType.GetEvents(bf)) { yield return(new XamlMember(ei, SchemaContext)); } }
public TypeContainer AddProperties(Predicate <PropertyInfo> property) { List <PropertyContainer> foo = new List <PropertyContainer>(); int cnt = 0; BindingFlags flags; if (includeInheritedProperties) { flags = BindingFlags.Public | BindingFlags.Instance; } else { flags = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance; } foreach (var c in UnderlyingType.GetProperties(flags).Where(x => property(x))) { if (c.IsWritable() || includeReadOnlyProperties) { if (setFirstPropertyPrimaryKey && cnt == 0) { foo.Add(new PropertyContainer(c, cnt++, true)); } else { foo.Add(new PropertyContainer(c, cnt++, false)); } } } Properties = foo; return(this); }
internal void LookupAllMembers(out ICollection <PropertyInfo> newProperties, out ICollection <EventInfo> newEvents, out List <XamlMember> knownMembers) { Debug.Assert(UnderlyingType != null, "Caller should check for UnderlyingType == null"); Debug.Assert(_nonAttachableMemberCache != null, "Members property should have been invoked before this"); PropertyInfo[] propList = UnderlyingType.GetProperties(AllProperties_BF); EventInfo[] eventList = UnderlyingType.GetEvents(AllProperties_BF); knownMembers = new List <XamlMember>(propList.Length + eventList.Length); newProperties = FilterProperties(propList, knownMembers, true); newEvents = FilterEvents(eventList, knownMembers); }
public override IEnumerable <IProperty> GetProperties(Predicate <IProperty> filter = null, GetMemberOptions options = GetMemberOptions.None) { return(UnderlyingType.GetProperties(filter, options)); }
/// <summary> /// Method called when FilterColumns property changes /// </summary> /// <exception cref="InvalidOperationException"> /// Raised when a a property filter refers to a non existing candidate object type property /// </exception> private void SetFilterColumns() { var propertyFilters = Items.Cast <ValueFilter>().ToList(); if (UnderlyingType.Equals(typeof(string)) || UnderlyingType.IsValueType) { // for native types, only one ValueFilter accepted to apply string format or IValueConverter if (propertyFilters.Count > 1) { throw new InvalidOperationException( "Only one property filter is authorized when underlying type is String or a value type."); } // Then if there is no property filter at all, there is no conversion needed and we build a defautl property getter // and there is one, we build a property getter accordingly _valueGetters.Add(propertyFilters.Count == 0 ? new PropertyFilterValueGetter(new ValueFilter()) : new PropertyFilterValueGetter(propertyFilters[0])); } // if the underlying type if neither a string nor value type, then it is a reference type else { IEnumerable <PropertyFilter> apfs; // if there is no PropertyFilter defined, we build it by default based on every instance public properties of the underlying type if (propertyFilters.Count == 0) { apfs = new List <PropertyFilter>(); // Get the type Properties var pis = UnderlyingType.GetProperties(BindingFlags.Public | BindingFlags.Instance); // iterate foreach (var propertyInfo in pis) { var pf = new PropertyFilter(propertyInfo.Name, DefaultMonitorPropertyChanges); var pfvg = new PropertyFilterValueGetter(pf, UnderlyingType); // Generate... _valueGetters.Add(pfvg); // ...and add value getter for each properties } } else { // and thus every ValueFilter must be PropertyFilter if (propertyFilters.Any(p => !(p is PropertyFilter))) { throw new InvalidOperationException("ValueFilter can't be used with reference type."); } apfs = propertyFilters.Cast <PropertyFilter>().ToList(); foreach (PropertyFilter pf in apfs) { // Get the PropertyInfo PropertyInfo pi = UnderlyingType.GetProperty(pf.FieldName); // this info is mandatory if (pi == null) { throw new InvalidOperationException( string.Format("Cant't find the property {0} for type {1}", pf.FieldName, UnderlyingType.Name)); } // If pi is ok, build the value getter and add it to the list var pfvg = new PropertyFilterValueGetter(pf, UnderlyingType); _valueGetters.Add(pfvg); } } // If there is no ValueFilter which is set to be monitored for property changes, we keep track of it to avoid to subscribe to propertychanged event later on _hasAnyPropertyChangesToMonitor = apfs.Any(p => p.MonitorPropertyChanged); } }