protected override void Execute(NativeActivityContext context) { if (!IsEnabled.Get(context)) { return; } var datacontext = context.DataContext; var properties = datacontext.GetProperties(); Action <IBaseManager, NotifyCollectionChangedAction, IList> ivokeHandler = (mngInstance, chngAction, data) => { DispatcherHelper.BeginInvoke(new Action(() => { mngInstance.RiseManagerChanged(chngAction, data); })); }; var mto = IoC.Instance.Resolve <IManagerForObject>(); foreach (var entity in EntityTypes) { if (string.IsNullOrEmpty(entity.Name)) { continue; } var type = mto.GetTypeByName(entity.Name); if (type == null) { throw new DeveloperException("Unknown source type '{0}'.", entity.Name); } var mgrType = mto.GetManagerByTypeName(type.Name); if (mgrType == null) { throw new DeveloperException(string.Format("Unknown source type '{0}'.", type.Name)); } using (var managerInstance = IoC.Instance.Resolve(mgrType, null) as IBaseManager) { if (managerInstance == null) { throw new DeveloperException(string.Format("Can't resolve IBaseManager by '{0}'.", mgrType.Name)); } if (!string.IsNullOrEmpty(entity.Caption) && entity.Value != null) { var action = (RefreshAction)Enum.Parse(typeof(RefreshAction), entity.Value.ToString()); if (action != RefreshAction.Changed) { var prop = properties.Find(entity.Caption, true); if (prop != null) { var ld = prop.GetValue(datacontext); if (ld != null) { var listData = ld as IList; switch (action) { case RefreshAction.InsertOrUpdate: //managerInstance.RiseManagerChanged(NotifyCollectionChangedAction.Add, listData); ivokeHandler(managerInstance, NotifyCollectionChangedAction.Add, listData); break; case RefreshAction.Remove: //managerInstance.RiseManagerChanged(NotifyCollectionChangedAction.Remove, listData); ivokeHandler(managerInstance, NotifyCollectionChangedAction.Remove, listData); break; } continue; } } } } managerInstance.RiseManagerChanged(); } } }