示例#1
0
        internal IReadOnlyList <MutableObject> MGetMembers(MutableObjectBase obj)
        {
            List <MutableObject> result = new List <MutableObject>();

            foreach (var prop in obj.MProperties)
            {
                if (prop.CanResolve)
                {
                    if (prop.IsCollection)
                    {
                        var items = this.GetList <MutableObject>(obj, prop);
                        if (items != null)
                        {
                            foreach (var item in items)
                            {
                                if (item != null && !result.Contains(item))
                                {
                                    result.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        var item = this.GetValue(obj.MId, prop) as MutableObject;
                        if (item != null && !result.Contains(item))
                        {
                            result.Add(item);
                        }
                    }
                }
            }
            return(result);
        }
示例#2
0
        internal MutableModelList <T> GetList <T>(MutableObjectBase obj, ModelProperty property)
        {
            Debug.Assert(property.IsCollection);
            var slot = obj.MId.Descriptor.GetSlot(property);

            return(MutableModelList <T> .FromGreenList(obj, slot));
        }
示例#3
0
 private void CollectBases(MutableObjectBase obj, List <MutableObject> result)
 {
     foreach (var prop in obj.MProperties)
     {
         if (prop.IsImport)
         {
             if (prop.IsCollection)
             {
                 var items = this.GetList <MutableObject>(obj, prop);
                 if (items != null)
                 {
                     foreach (var item in items)
                     {
                         if (item != null && !result.Contains(item))
                         {
                             result.Add(item);
                         }
                     }
                 }
             }
             else
             {
                 var item = this.GetValue(obj.MId, prop) as MutableObject;
                 if (item != null && !result.Contains(item))
                 {
                     result.Add(item);
                 }
             }
         }
     }
 }
示例#4
0
        internal IReadOnlyList <MutableObject> MGetAllBases(MutableObjectBase obj)
        {
            List <MutableObject> result = new List <MutableObject>();

            this.CollectAllBases(obj, result);
            result.Remove(obj);
            return(result);
        }
示例#5
0
 internal static MutableModelList <T> FromGreenList(MutableObjectBase obj, Slot slot)
 {
     if (slot.IsCollection)
     {
         return(new MutableModelListFromGreenList <T>(obj, slot));
     }
     else
     {
         return(new MutableModelListFromGreenSingle <T>(obj, slot));
     }
 }
示例#6
0
 internal object MGet(MutableObjectBase obj, ModelProperty property)
 {
     if (property.IsCollection)
     {
         return(this.GetList <object>(obj, property));
     }
     else
     {
         return(this.GetValue(obj.MId, property));
     }
 }
示例#7
0
        protected MutableObject CreateObject(ObjectId id)
        {
            MutableObjectBase obj = this.model.CreateObject(id, this.flags.HasFlag(ModelFactoryFlags.CreateWeakObjects));

            obj.MCallInit();
            if (!this.flags.HasFlag(ModelFactoryFlags.DontMakeObjectsCreated))
            {
                obj.MMakeCreated();
            }
            return(obj);
        }
示例#8
0
        private void CollectAllBases(MutableObjectBase obj, List <MutableObject> result)
        {
            if (obj == null)
            {
                return;
            }

            if (!result.Contains(obj))
            {
                result.Add(obj);
                var bases = obj.MGetBases();
                foreach (var item in bases)
                {
                    this.CollectAllBases(item as MutableObjectBase, result);
                }
            }
        }
示例#9
0
        internal MutableObjectBase CreateObject(ObjectId oid, bool weakReference)
        {
            Debug.Assert(oid != null);
            Debug.Assert(!this.ContainsObject(oid));
            MutableObjectBase result = null;

            result = oid.CreateMutable(this, true);
            GreenModelUpdateContext ctx = null;

            try
            {
                do
                {
                    ctx = this.BeginUpdate();
                    ctx.Updater.AddObject(this.id, oid, weakReference);
                } while (!this.EndUpdate(ctx));
                this.RegisterObject(oid, result);
            }
            finally
            {
                this.FinalizeUpdate(ctx);
            }
            return(result);
        }
示例#10
0
 internal MutableModelListFromGreenList(MutableObjectBase obj, Slot slot)
 {
     this.obj  = obj;
     this.slot = slot;
 }
示例#11
0
 internal MutableModelSetFromGreenSingle(MutableObjectBase obj, Slot slot)
 {
     this.obj  = obj;
     this.slot = slot;
 }