protected virtual void InspectProperties(ComponentModel model) { var targetType = model.Implementation; #if SILVERLIGHT if(targetType.IsVisible == false) return; #endif if (model.InspectionBehavior == PropertiesInspectionBehavior.Undefined) { model.InspectionBehavior = GetInspectionBehaviorFromTheConfiguration(model.Configuration); } if (model.InspectionBehavior == PropertiesInspectionBehavior.None) { // Nothing to be inspected return; } var properties = GetProperties(model, targetType); if (properties.Count == 0) { return; } var filters = StandardPropertyFilters.GetPropertyFilters(model, false); if (filters == null) { properties.ForEach(p => model.AddProperty(BuildDependency(p, isOptional: true))); } else { foreach (var filter in filters.Concat(new[] { StandardPropertyFilters.Create(PropertyFilter.Default) })) { var dependencies = filter.Invoke(model, properties, BuildDependency); if (dependencies != null) { foreach (var dependency in dependencies) { model.AddProperty(dependency); } } if (properties.Count == 0) { return; } } } }
protected virtual void InspectProperties(ComponentModel model) { var targetType = model.Implementation; #if SILVERLIGHT if(targetType.IsVisible == false) return; #endif if (model.InspectionBehavior == PropertiesInspectionBehavior.Undefined) { model.InspectionBehavior = GetInspectionBehaviorFromTheConfiguration(model.Configuration); } if (model.InspectionBehavior == PropertiesInspectionBehavior.None) { // Nothing to be inspected return; } BindingFlags bindingFlags; if (model.InspectionBehavior == PropertiesInspectionBehavior.DeclaredOnly) { bindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; } else // if (model.InspectionBehavior == PropertiesInspectionBehavior.All) or Undefined { bindingFlags = BindingFlags.Public | BindingFlags.Instance; } var properties = targetType.GetProperties(bindingFlags); var filters = GetPropertyFilters(model); foreach (var property in properties) { if (!property.CanWrite || property.GetSetMethod() == null) { continue; } var indexerParams = property.GetIndexParameters(); if (indexerParams != null && indexerParams.Length != 0) { continue; } if (property.IsDefined(typeof(DoNotWireAttribute), true)) { continue; } if (filters != null && filters.Any(f => f(property) == false)) { continue; } var dependency = new DependencyModel(property.Name, property.PropertyType, isOptional: true); model.AddProperty(new PropertySet(property, dependency)); } }