Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        /// <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();
            }
        }
Esempio n. 4
0
        /// <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);
            }
        }
Esempio n. 5
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;
            var scope = EventScope.CreateScope(config, this.GetTypeName(), property);

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                BeforePropertyChanged(property, oldValue, newValue);
            }
        }
Esempio n. 6
0
        /// <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);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 完成代码生成
        /// </summary>
        public static void OnCodeGeneratorEnd()
        {
            var scope = EventScope.CreateScope(My, "Global", "OnCodeGeneratorEnd");

            if (scope == null)
            {
                return;
            }
            using (scope)
            {
                foreach (var trigger in Triggers)
                {
                    trigger.OnCodeGeneratorEnd();
                }
            }
        }
Esempio n. 8
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);
                    }
                }
            }
        }
Esempio n. 9
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);
                }
            }
        }
Esempio n. 10
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);
                    }
                }
            }
        }