コード例 #1
0
        /// <summary>
        /// 构造事件处理
        /// </summary>
        /// <param name="config"></param>
        public static void OnCreate(NotificationObject config)
        {
            if (NotificationObject.IsLoadingMode)
            {
                return;
            }
            var type  = config.GetType();
            var scope = EventScope.CreateScope(config, "_create_");

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                foreach (var trigger in Triggers)
                {
                    if (trigger.TargetType == type || type.IsSubclassOf(trigger.TargetType))
                    {
                        trigger.OnCreate(config);
                    }
                }
            }
            OnLoad(config);
        }
コード例 #2
0
        /// <summary>
        /// 构造事件处理
        /// </summary>
        /// <param name="config"></param>
        public static void OnCreate(NotificationObject config)
        {
            if (config == null)
            {
                return;
            }
            var type  = config.GetType();
            var scope = EventScope.CreateScope(config, "Global", "OnCreate");

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                foreach (var trigger in Triggers)
                {
                    if (trigger.TargetType == null || trigger.TargetType == type || type.IsSubclassOf(trigger.TargetType))
                    {
                        trigger.OnCreate(config);
                    }
                }
            }
            if (WorkContext.IsNoChangedNotify)
            {
                return;
            }
            OnLoad(config);
        }
コード例 #3
0
 /// <summary>
 /// 构造事件处理
 /// </summary>
 /// <param name="config"></param>
 public static void OnCtor(NotificationObject config)
 {
     if (WorkContext.IsNoChangedNotify || config == null)
     {
         return;
     }
     Dispatcher.Invoke(() => OnCreate(config));
 }
コード例 #4
0
 CodeGeneratorScope(NotificationObject config)
 {
     _innerScope = WorkModelScope.CreateScope(WorkModel.Coder);
     if (config == null)
     {
         return;
     }
     GlobalTrigger.OnCodeGeneratorBegin(config);
 }
コード例 #5
0
 /// <summary>
 /// 找对应节点
 /// </summary>
 /// <returns></returns>
 public TreeItem Find(NotificationObject obj)
 {
     if (obj == null || Items.Count == 0)
     {
         return(null);
     }
     if (Source == obj)
     {
         return(this);
     }
     return(Items.Select(child => child.Find(obj)).FirstOrDefault(item => item != null));
 }
コード例 #6
0
ファイル: EventTrigger.cs プロジェクト: ym1100/MicroZero
        /// <summary>
        ///     发出属性修改前事件
        /// </summary>
        /// <param name="config"></param>
        /// <param name="property">属性</param>
        /// <param name="oldValue">旧值</param>
        /// <param name="newValue">新值</param>
        public void BeforePropertyChanged(NotificationObject config, string property, object oldValue, object newValue)
        {
            Target = config;
            var scope = EventScope.CreateScope(config, this.GetTypeName(), property);

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                BeforePropertyChanged(property, oldValue, newValue);
            }
        }
コード例 #7
0
ファイル: EventTrigger.cs プロジェクト: ym1100/MicroZero
        /// <summary>
        /// 属性事件处理
        /// </summary>
        /// <param name="config"></param>
        /// <param name="property"></param>
        internal void OnPropertyChanged(NotificationObject config, string property)
        {
            Target = config;
            var scope = EventScope.CreateScope(config, this.GetTypeName(), property);

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                OnPropertyChanged(property);
            }
        }
コード例 #8
0
ファイル: EventTrigger.cs プロジェクト: ym1100/MicroZero
        /// <summary>
        /// 载入事件处理
        /// </summary>
        /// <param name="config"></param>
        public void OnCreate(NotificationObject config)
        {
            Target = config;
            var scope = EventScope.CreateScope(config, this.GetTypeName(), "_create_");

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                OnCreate();
            }
        }
コード例 #9
0
ファイル: EventTrigger.cs プロジェクト: ym1100/MicroZero
        /// <summary>
        /// 删除事件处理
        /// </summary>
        /// <param name="config"></param>
        /// <param name="parent"></param>
        public void OnRemoved(NotificationObject parent, NotificationObject config)
        {
            Target = parent;
            var scope = EventScope.CreateScope(config, this.GetTypeName(), "_del_");

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                OnRemoved(config);
            }
        }
コード例 #10
0
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="config">配置</param>
        /// <param name="property">属性</param>
        /// <returns>为空表示已重入,应该放弃处理,不为空则使用这个范围</returns>
        public static EventScope CreateScope(NotificationObject config, string property)
        {
            List <string> events;

            if (Events.TryGetValue(config, out events))
            {
                if (events.Contains(property))
                {
                    return(null);
                }
            }
            else
            {
                Events.Add(config, new List <string>());
            }
            return(new EventScope(config, property));
        }
コード例 #11
0
        /// <summary>
        /// 删除事件处理
        /// </summary>
        /// <param name="config"></param>
        /// <param name="parent"></param>
        public static void OnRemoved(NotificationObject parent, NotificationObject config)
        {
            var type  = config.GetType();
            var scope = EventScope.CreateScope(config, "_remove_");

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                foreach (var trigger in Triggers)
                {
                    if (trigger.TargetType == type || type.IsSubclassOf(trigger.TargetType))
                    {
                        trigger.OnRemoved(config, config);
                    }
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// 开始代码生成
        /// </summary>
        public static void OnCodeGeneratorBegin(NotificationObject config)
        {
            if (config == null)
            {
                return;
            }
            var scope = EventScope.CreateScope(My, "Global", "OnCodeGeneratorBegin");

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                foreach (var trigger in Triggers)
                {
                    trigger.OnCodeGeneratorBegin(config);
                }
            }
        }
コード例 #13
0
        /// <summary>
        ///     发出属性修改前事件
        /// </summary>
        /// <param name="config"></param>
        /// <param name="property">属性</param>
        /// <param name="oldValue">旧值</param>
        /// <param name="newValue">新值</param>
        public static void BeforePropertyChanged(NotificationObject config, string property, object oldValue, object newValue)
        {
            if (NotificationObject.IsLoadingMode)
            {
                return;
            }
            var type  = config.GetType();
            var scope = EventScope.CreateScope(config, property);

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                foreach (var trigger in Triggers)
                {
                    if (trigger.TargetType == type || type.IsSubclassOf(trigger.TargetType))
                    {
                        trigger.BeforePropertyChanged(config, property, oldValue, newValue);
                    }
                }
            }
        }
コード例 #14
0
 /// <summary>
 /// 删除事件处理
 /// </summary>
 /// <param name="config"></param>
 /// <param name="parent"></param>
 public void OnRemoved(NotificationObject parent, NotificationObject config)
 {
     Target = parent;
     OnRemoved(config);
 }
コード例 #15
0
 /// <summary>
 /// 载入事件处理
 /// </summary>
 /// <param name="config"></param>
 public void OnLoad(NotificationObject config)
 {
     Target = config;
     OnLoad();
 }
コード例 #16
0
 /// <summary>
 /// 属性事件处理
 /// </summary>
 /// <param name="config"></param>
 /// <param name="property"></param>
 internal void OnPropertyChanged(NotificationObject config, string property)
 {
     Target = config;
     OnPropertyChanged(property);
 }
コード例 #17
0
 /// <summary>
 /// 构造
 /// </summary>
 /// <param name="config"></param>
 /// <param name="property"></param>
 private EventScope(NotificationObject config, string property)
 {
     _config   = config;
     _property = property;
     Events[config].Add(property);
 }
コード例 #18
0
 /// <summary>
 /// 找对应节点
 /// </summary>
 /// <returns></returns>
 public TreeItem Find(NotificationObject obj)
 {
     return(Items.Select(child => child.Find(obj)).FirstOrDefault(item => item != null));
 }
コード例 #19
0
 /// <summary>
 /// 生成范围
 /// </summary>
 /// <returns></returns>
 public static IDisposable CreateScope(NotificationObject config)
 {
     return(new CodeGeneratorScope(config));
 }
コード例 #20
0
 /// <summary>
 ///     发出属性修改前事件
 /// </summary>
 /// <param name="config"></param>
 /// <param name="property">属性</param>
 /// <param name="oldValue">旧值</param>
 /// <param name="newValue">新值</param>
 public void BeforePropertyChanged(NotificationObject config, string property, object oldValue, object newValue)
 {
     Target = config;
     BeforePropertyChanged(property, oldValue, newValue);
 }
コード例 #21
0
ファイル: EventTrigger.cs プロジェクト: ym1100/MicroZero
 /// <summary>
 /// 开始代码生成
 /// </summary>
 public virtual void OnCodeGeneratorBegin(NotificationObject config)
 {
 }
コード例 #22
0
ファイル: EventTrigger.cs プロジェクト: ym1100/MicroZero
 /// <summary>
 /// 删除事件处理
 /// </summary>
 /// <param name="config"></param>
 protected virtual void OnRemoved(NotificationObject config)
 {
 }
コード例 #23
0
ファイル: EventTrigger.cs プロジェクト: ym1100/MicroZero
 /// <summary>
 /// 加入事件处理
 /// </summary>
 /// <param name="config"></param>
 protected virtual void OnAdded(NotificationObject config)
 {
 }