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( 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 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 ExplicitDependencyMap AnalyzeType(Type type)
        {
            //We need to grab all the properties and build a map of their dependencies

            IEnumerable <PropertyInfo> allProperties =
                type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
                .Where(p => !p.IsInpcIgnoredMethod()).ToList();

            IEnumerable <PropertyInfo> propertiesForImplicitAnalasis =
                allProperties;

            //var propertiesForExplicitAnalasis =
            //    allProperties.Select( p => new { Property = p, DependsOnAttributes = p.GetCustomAttributes( typeof(DependsOnAttribute), false ) } ).Where(
            //        p => p.DependsOnAttributes.Any() );

            // build ExplicitDependencyMap. We need it here to add invocation chains.
            ExplicitDependencyMap currentTypeExplicitDependencyMap = new ExplicitDependencyMap();

            //propertiesForExplicitAnalasis.Select(
            //    p => new ExplicitDependency( p.Property.Name, p.DependsOnAttributes.SelectMany( d => ((DependsOnAttribute)d).Dependencies ) ) ) );

            foreach (PropertyInfo propertyInfo in propertiesForImplicitAnalasis)
            {
                if (!propertyInfo.CanRead)
                {
                    continue;
                }

                this.methodAnalyzer.AnalyzeProperty(type, propertyInfo, currentTypeExplicitDependencyMap);

                IList <FieldInfo> fieldList;

                //Time to build the reversed graph, i.e. field->property dependencies

                if (this.methodAnalyzer.MethodFieldDependencies.TryGetValue(propertyInfo.GetGetMethod(), out fieldList))
                {
                    foreach (FieldInfo field in fieldList)
                    {
                        IList <string> propertyList = this.fieldDependentProperties.GetOrCreate(field.FullName(), () => new List <string>());

                        propertyList.AddIfNew(propertyInfo.Name);
                    }
                }
            }

            return(currentTypeExplicitDependencyMap);
        }
        public ExplicitDependencyMap AnalyzeType( Type type )
        {
            //We need to grab all the properties and build a map of their dependencies

            IEnumerable<PropertyInfo> allProperties =
                type.GetProperties( BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly )
                    .Where( p => !p.IsInpcIgnoredMethod() ).ToList();

            IEnumerable<PropertyInfo> propertiesForImplicitAnalasis =
                allProperties;

            //var propertiesForExplicitAnalasis =
            //    allProperties.Select( p => new { Property = p, DependsOnAttributes = p.GetCustomAttributes( typeof(DependsOnAttribute), false ) } ).Where(
            //        p => p.DependsOnAttributes.Any() );

            // build ExplicitDependencyMap. We need it here to add invocation chains.
            ExplicitDependencyMap currentTypeExplicitDependencyMap = new ExplicitDependencyMap();
                    //propertiesForExplicitAnalasis.Select(
                    //    p => new ExplicitDependency( p.Property.Name, p.DependsOnAttributes.SelectMany( d => ((DependsOnAttribute)d).Dependencies ) ) ) );

            foreach ( PropertyInfo propertyInfo in propertiesForImplicitAnalasis )
            {
                if ( !propertyInfo.CanRead )
                {
                    continue;
                }

                this.methodAnalyzer.AnalyzeProperty( type, propertyInfo, currentTypeExplicitDependencyMap );

                IList<FieldInfo> fieldList;

                //Time to build the reversed graph, i.e. field->property dependencies

                if ( this.methodAnalyzer.MethodFieldDependencies.TryGetValue( propertyInfo.GetGetMethod(), out fieldList ) )
                {
                    foreach ( FieldInfo field in fieldList )
                    {
                        IList<string> propertyList = this.fieldDependentProperties.GetOrCreate( field.FullName(), () => new List<string>() );

                        propertyList.AddIfNew( propertyInfo.Name );
                    }
                }
            }

            return currentTypeExplicitDependencyMap;
        }
            public void AnalyzeProperty(Type type, PropertyInfo propertyInfo, ExplicitDependencyMap currentTypeExplicitDependencyMap)
            {
                if (this.context.Current != null)
                {
                    throw new NotSupportedException("MethodAnalyzer is currently single-threaded!");
                }

                MethodInfo propertyGetter = propertyInfo.GetGetMethod(false);

                if (propertyGetter == null)
                {
                    return;
                }

                using (this.context.InContext(() => new AnalysisContext(type, propertyGetter, propertyInfo, currentTypeExplicitDependencyMap)))
                {
                    this.AnalyzeMethodRecursive(propertyGetter);
                }
            }
 public AnalysisContext(Type currentType, MethodBase currentMethod, PropertyInfo currentProperty, ExplicitDependencyMap explicitDependencyMap)
 {
     this.CurrentType           = currentType;
     this.CurrentMethod         = currentMethod;
     this.CurrentProperty       = currentProperty;
     this.ExplicitDependencyMap = explicitDependencyMap;
 }
 public AnalysisContext( Type currentType, MethodBase currentMethod, PropertyInfo currentProperty, ExplicitDependencyMap explicitDependencyMap )
 {
     this.CurrentType = currentType;
     this.CurrentMethod = currentMethod;
     this.CurrentProperty = currentProperty;
     this.ExplicitDependencyMap = explicitDependencyMap;
 }
            public void AnalyzeProperty( Type type, PropertyInfo propertyInfo, ExplicitDependencyMap currentTypeExplicitDependencyMap )
            {
                if ( this.context.Current != null )
                {
                    throw new NotSupportedException( "MethodAnalyzer is currently single-threaded!" );
                }

                MethodInfo propertyGetter = propertyInfo.GetGetMethod( false );

                if ( propertyGetter == null )
                {
                    return;
                }

                using ( this.context.InContext( () => new AnalysisContext( type, propertyGetter, propertyInfo, currentTypeExplicitDependencyMap ) ) )
                {
                    this.AnalyzeMethodRecursive( propertyGetter );
                }
            }