Beispiel #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);
        }
Beispiel #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));
        }
Beispiel #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);
                 }
             }
         }
     }
 }
Beispiel #4
0
        internal IReadOnlyList <MutableObject> MGetAllBases(MutableObjectBase obj)
        {
            List <MutableObject> result = new List <MutableObject>();

            this.CollectAllBases(obj, result);
            result.Remove(obj);
            return(result);
        }
Beispiel #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));
     }
 }
Beispiel #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));
     }
 }
        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);
        }
Beispiel #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);
                }
            }
        }
Beispiel #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);
        }
Beispiel #10
0
 internal MutableModelListFromGreenList(MutableObjectBase obj, Slot slot)
 {
     this.obj  = obj;
     this.slot = slot;
 }
Beispiel #11
0
 internal MutableModelSetFromGreenSingle(MutableObjectBase obj, Slot slot)
 {
     this.obj  = obj;
     this.slot = slot;
 }