protected void BindToNesteds() { Type selfT = GetType(); // fields selfT.GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .Where(f => f.FieldType.IsSubclassOfRawGeneric(typeof(FilterObjectbase)) || f.FieldType.IsSubclassOfRawGeneric(typeof(FilterObjectsCollection <>))) .Select(field => field.GetValue(this)) .Cast <INotifyModelPropertyChanged>() .ToList() .ForEach(c => { if (!ReferenceEquals(null, c)) { //remove old changed handler c.ModelPropertyChanged += OnNestedPropertyChanged; } }); AfterBindToNesteds(); if (ReferenceEquals(null, _tcd)) { _tcd = TypeCache.GetTypeCacheData(GetType()); } // handle conversion attributes for fields IEnumerable <PropertyInfo> pps = _tcd.GetPropertiesWithAttributeType(typeof(CustomConverterAttribute)).ToList(); foreach (PropertyInfo pi in pps) { IHasConverter ff = selfT.GetField("_" + pi.Name, BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this) as IHasConverter; if (!ReferenceEquals(null, ff)) { CustomConverterAttribute a = _tcd.GetCustomTypedAttributesForProperty(pi.Name, typeof(CustomConverterAttribute)).First() as CustomConverterAttribute; ff.Converter = a; } } }
public void CustomConverterAttribute_WithTypes_InstanceTypeAsExpected(Type type) { CustomConverterAttribute actual = new CustomConverterAttribute(type); Assert.That(actual.Instance, Is.EqualTo(type)); }