示例#1
0
        /// <summary>
        /// 对象初始化函数,对象被创建时,这个函数将被调用
        /// </summary>
        /// <param name="item">扩展对象</param>
        /// <param name="args">参数</param>
        public virtual void OnDoCreate(ExtendObject item, params object[] args)
        {
            OwnerType = this.GetType();
            var plist = ExtendPropertysProvider.GetByType(OwnerType).ToList();

            if (plist.Count <= 0)
            {
                plist = ExtendPropertysProvider.GetByType(OwnerType.BaseType).ToList();
            }

            var types = plist.Where(p => childrenTypes.Values.Any(cp => cp == p.PropertyType)).ToDictionary(m => m.PropertyName, e => e.PropertyType);

            foreach (var children in types)
            {
                var info = OwnerType.GetProperty(children.Key);
                if (info != null)
                {
                    var childObj = info.GetValue(this, null) as ExtendObject;
                    if (childObj != null)
                    {
                        objects.Add(childObj);
                        childObj.ChildrenPropertyChanged -=
                            new EventHandler <ExtendPropertyValueChangedArgs>(exObject_ChildrenPropertyChanged);
                        childObj.ChildrenPropertyChanged +=
                            new EventHandler <ExtendPropertyValueChangedArgs>(exObject_ChildrenPropertyChanged);
                    }
                }
                var childObjPropertyInfoList = ExtendPropertysProvider.GetByType(children.Value);
                foreach (var extendProperty in childObjPropertyInfoList)
                {
                    extendProperty.ValueChanged -=
                        new EventHandler <ExtendPropertyValueChangedArgs>(exObject_ChildrenPropertyChanged);

                    extendProperty.ValueChanged +=
                        new EventHandler <ExtendPropertyValueChangedArgs>(exObject_ChildrenPropertyChanged);
                }
            }
        }
示例#2
0
 public override void OnDoCreate(ExtendPropertyLib.ExtendObject item, params object[] args)
 {
     base.OnDoCreate(item, args);
     OpenDocuments = new ObservableCollection <DocumentInfo>();
     ApplicationService.Services.Add <InteractiveManager>(InteractiveManager);
 }
示例#3
0
 public ExtendDynamicObject(ExtendObject exObject)
 {
     extendObject = exObject;
 }