private ChildPropertyChangedProcessor(
     PropertyFieldBindingsMap propertyToFieldBindings, FieldValueComparer fieldValueComparer, ExplicitDependencyMap explicitDependencyMap)
 {
     this.fieldValueComparer      = fieldValueComparer;
     this.explicitDependencyMap   = explicitDependencyMap;
     this.propertyToFieldBindings = propertyToFieldBindings;
 }
 public override void CompileTimeInitialize( Type type, AspectInfo aspectInfo )
 {
     this.explicitDependencyMap = analyzer.Value.AnalyzeType( type );
     this.fieldValueComparer = new FieldValueComparer( type );
     this.childPropertyChangedProcessor = ChildPropertyChangedProcessor.CompileTimeCreate(
         type, analyzer.Value.MethodFieldDependencies, this.fieldValueComparer, this.explicitDependencyMap );
 }
 private ChildPropertyChangedProcessor(
     PropertyFieldBindingsMap propertyToFieldBindings, FieldValueComparer fieldValueComparer, ExplicitDependencyMap explicitDependencyMap )
 {
     this.fieldValueComparer = fieldValueComparer;
     this.explicitDependencyMap = explicitDependencyMap;
     this.propertyToFieldBindings = propertyToFieldBindings;
 }
 private PropertyFieldBindingsMap( PropertyFieldBindingsMap prototype )
 {
     this.propertyToFieldMapping = prototype.propertyToFieldMapping.ToDictionary(
         kv => kv.Key, kv => kv.Value.Select( b => new PropertyFieldBinding( b ) ).ToList() );
     this.fieldValueComparer = prototype.fieldValueComparer;
     this.fieldToPropertyMapping = prototype.fieldToPropertyMapping;
     this.filedInfos = prototype.FiledInfos;
 }
예제 #5
0
 private PropertyFieldBindingsMap(PropertyFieldBindingsMap prototype)
 {
     this.propertyToFieldMapping = prototype.propertyToFieldMapping.ToDictionary(
         kv => kv.Key, kv => kv.Value.Select(b => new PropertyFieldBinding(b)).ToList());
     this.fieldValueComparer     = prototype.fieldValueComparer;
     this.fieldToPropertyMapping = prototype.fieldToPropertyMapping;
     this.filedInfos             = prototype.FiledInfos;
 }
 private ChildPropertyChangedProcessor(ChildPropertyChangedProcessor prototype, object instance)
 {
     this.instance                           = instance;
     this.fieldValueComparer                 = prototype.fieldValueComparer;
     this.explicitDependencyMap              = prototype.explicitDependencyMap;
     this.propertyToFieldBindings            = PropertyFieldBindingsMap.CreateFromPrototype(prototype.propertyToFieldBindings);
     this.notifyChildPropertyChangedHandlers = new Dictionary <string, NotifyChildPropertyChangedEventHandlerDescriptor>();
 }
 private ChildPropertyChangedProcessor( ChildPropertyChangedProcessor prototype, object instance )
 {
     this.instance = instance;
     this.fieldValueComparer = prototype.fieldValueComparer;
     this.explicitDependencyMap = prototype.explicitDependencyMap;
     this.propertyToFieldBindings = PropertyFieldBindingsMap.CreateFromPrototype( prototype.propertyToFieldBindings );
     this.notifyChildPropertyChangedHandlers = new Dictionary<string, NotifyChildPropertyChangedEventHandlerDescriptor>();
 }
        public PropertyFieldBindingsMap( Type type, FieldValueComparer fieldValueComparer )
        {
            this.propertyToFieldMapping = new Dictionary<string, List<PropertyFieldBinding>>();
            this.fieldToPropertyMapping = new Dictionary<string, List<string>>();
            this.fieldValueComparer = fieldValueComparer;

            this.filedInfos = type.GetFields( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).ToDictionary(
                f => f.Name, f => new FieldInfoWithCompiledGetter( f, type ) );
        }
예제 #9
0
        public PropertyFieldBindingsMap(Type type, FieldValueComparer fieldValueComparer)
        {
            this.propertyToFieldMapping = new Dictionary <string, List <PropertyFieldBinding> >();
            this.fieldToPropertyMapping = new Dictionary <string, List <string> >();
            this.fieldValueComparer     = fieldValueComparer;

            this.filedInfos = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).ToDictionary(
                f => f.Name, f => new FieldInfoWithCompiledGetter(f, type));
        }
 public static ChildPropertyChangedProcessor CompileTimeCreate(
     Type type,
     Dictionary<MethodBase, IList<FieldInfo>> methodFieldDependencies,
     FieldValueComparer fieldValueComparer,
     ExplicitDependencyMap explicitDependencyMap )
 {
     PropertyFieldBindingsMap propertyToFieldBindings = PropertyToFieldBindingGenerator.GenerateBindings(
         type, methodFieldDependencies, fieldValueComparer );
     return new ChildPropertyChangedProcessor( propertyToFieldBindings, fieldValueComparer, explicitDependencyMap );
 }
        public static ChildPropertyChangedProcessor CompileTimeCreate(
            Type type,
            Dictionary <MethodBase, IList <FieldInfo> > methodFieldDependencies,
            FieldValueComparer fieldValueComparer,
            ExplicitDependencyMap explicitDependencyMap)
        {
            PropertyFieldBindingsMap propertyToFieldBindings = PropertyToFieldBindingGenerator.GenerateBindings(
                type, methodFieldDependencies, fieldValueComparer);

            return(new ChildPropertyChangedProcessor(propertyToFieldBindings, fieldValueComparer, explicitDependencyMap));
        }
            public static PropertyFieldBindingsMap GenerateBindings(
                Type type, Dictionary <MethodBase, IList <FieldInfo> > methodFieldDependencies, FieldValueComparer fieldValueComparer)
            {
                // build propertyToFieldBindings
                PropertyFieldBindingsMap propertyToFieldBindings = new PropertyFieldBindingsMap(type, fieldValueComparer);

                PropertyInfo[] allProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

                foreach (PropertyInfo propertyInfo in allProperties)
                {
                    IList <FieldInfo> fieldList;
                    if (methodFieldDependencies.TryGetValue(propertyInfo.GetGetMethod(), out fieldList))
                    {
                        List <FieldInfo> matchingFields = fieldList.Where(f => propertyInfo.PropertyType.IsAssignableFrom(f.FieldType)).ToList();
                        propertyToFieldBindings.AddBindings(propertyInfo, matchingFields, type);
                    }
                }
                return(propertyToFieldBindings);
            }
            public static PropertyFieldBindingsMap GenerateBindings(
                Type type, Dictionary<MethodBase, IList<FieldInfo>> methodFieldDependencies, FieldValueComparer fieldValueComparer )
            {
                // build propertyToFieldBindings
                PropertyFieldBindingsMap propertyToFieldBindings = new PropertyFieldBindingsMap( type, fieldValueComparer );

                PropertyInfo[] allProperties = type.GetProperties( BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly );

                foreach ( PropertyInfo propertyInfo in allProperties )
                {
                    IList<FieldInfo> fieldList;
                    if ( methodFieldDependencies.TryGetValue( propertyInfo.GetGetMethod(), out fieldList ) )
                    {
                        List<FieldInfo> matchingFields = fieldList.Where( f => propertyInfo.PropertyType.IsAssignableFrom( f.FieldType ) ).ToList();
                        propertyToFieldBindings.AddBindings( propertyInfo, matchingFields, type );
                    }
                }
                return propertyToFieldBindings;
            }