private NotificationProfile(Type type, NotifyPropertyChangedAttribute behavior)
        {
            _dependencyMode = behavior.DependencyMode;

            var properties = type.GetProperties();

            _ignores = (from property in properties
                        where property.GetAttributes<DoNotNotifyAttribute>(true).Any()
                        select property.Name).ToList();

            var dependents = from property in properties
                             let dependencies = property.GetAttributes<DependenciesAttribute>(true)
                             where dependencies.Any()
                             from dependency in dependencies
                                 .SelectMany(x => x.Dependencies)
                                 .Distinct()
                             select new
                             {
                                 Property = property.Name,
                                 DependsOn = dependency
                             };

            foreach (var dependent in dependents)
            {
                GetOrCreateDependencies(dependent.DependsOn)
                    .Add(dependent.Property);

                if (!_recorded.Contains(dependent.Property))
                    _recorded.Add(dependent.Property);
            }
        }
        /// <summary>
        /// Gets the specified profile for the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="behavior">The behavior.</param>
        /// <returns>The profile.</returns>
        public static NotificationProfile Get(Type type, NotifyPropertyChangedAttribute behavior)
        {
            NotificationProfile profile;

            if(!_profiles.TryGetValue(type, out profile))
            {
                lock(_creationLock)
                {
                    if(!_profiles.TryGetValue(type, out profile))
                    {
                        _profiles[type] = profile = new NotificationProfile(type, behavior);
                    }
                }
            }

            return profile;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NotifyPropertyChangedNoInterfaceInterceptor"/> class.
 /// </summary>
 /// <param name="implementation">The implementation.</param>
 /// <param name="behavior">The behavior.</param>
 public NotifyPropertyChangedNoInterfaceInterceptor(Type implementation, NotifyPropertyChangedAttribute behavior) 
     : base(implementation, behavior) {}
示例#4
0
 public OnPropertySetSubAspect(string propertyName, NotifyPropertyChangedAttribute parent)
 {
     this.AspectPriority = parent.AspectPriority;
     this.propertyName   = propertyName;
 }
示例#5
0
 public OnPropertySetSubAspect(string propertyName, NotifyPropertyChangedAttribute parent)
 {
     this.AspectPriority = parent.AspectPriority;
     this.propertyName = propertyName;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NotifyPropertyChangedBaseInterceptor"/> class.
 /// </summary>
 /// <param name="implementation">The implementation.</param>
 /// <param name="behavior">The behavior.</param>
 protected NotifyPropertyChangedBaseInterceptor(Type implementation, NotifyPropertyChangedAttribute behavior)
 {
     _profile = NotificationProfile.Get(implementation, behavior);
 }