コード例 #1
0
 public override void End(ScopeContext context, bool result)
 {
     //base.End(context, result);
     //if (result && _notificationAction != null)
     //{
     //    var group = context.Get<ScopeRecorder>()
     //           ?.Records
     //            .OfType<PropertyChangeRecord>()
     //            .Where(r => r.Target is IPropertyChangedNotifier)
     //            .Distinct(_comparer)
     //            .Select(r => new { Record = r, Property = r.PropertyName })
     //            .GroupBy(r => r.Record.Target);
     //    foreach (var g in group)
     //        _notificationAction(g.Key, g.Select(r => r.Property).ToArray());
     //}
     base.End(context, result);
     if (result && _notificationAction != null)
     {
         var group = context.Get<ScopeRecorder>()
                            ?.Records
                             .OfType<IPropertyChangeRecord>()
                             .Where(r => r.Target is IPropertyChangedNotifier)
                             .Distinct(_comparer)
                             .Select(r => new { Record = r, Property = r.PropertyName })
                             .GroupBy(r => r.Record.Target);
         foreach (var g in group)
             _notificationAction(g.Key, g.Select(r => r.Property).ToArray());
     }
 }
コード例 #2
0
        public static void TryRecordOrElseNotify<TOwner>(ScopeContext scopeContext, TOwner owner, string propertyName, NotifyCollectionChangedEventArgs args, bool isRecordingEnabled)
            where TOwner : IPropertyChangedNotifier
        {
            var notify = false;
            if (scopeContext != null && isRecordingEnabled)
            {
                scopeContext.Get<ScopeRecorder>()
                            ?.Record(scopeContext,
                                     new CollectionChangeRecord(owner, propertyName, args));

                if (!scopeContext.ContainsKey<PropertyNotificationScopeAspect>())
                    notify = true;
            }
            else notify = true;
            if (notify)
                PropertyNotificationManager<TOwner>.PropagateNotification(owner, propertyName);
        }