public MutableObject ToMutable(MutableModel mutableModel)
 {
     if (mutableModel == null)
     {
         throw new ArgumentNullException(nameof(mutableModel));
     }
     return(mutableModel.GetObject(this));
 }
Esempio n. 2
0
 internal ImmutableModel(GreenModel green, MutableModel mutableModel)
 {
     this.id           = green.Id;
     this.group        = null;
     this.green        = green;
     this.readOnly     = false;
     this.objects      = new ConditionalWeakTable <ObjectId, ImmutableObject>();
     this.mutableModel = new WeakReference <MutableModel>(mutableModel);
 }
Esempio n. 3
0
 public ModelFactoryBase(MutableModel model, ModelFactoryFlags flags = ModelFactoryFlags.None)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     this.model = model;
     this.flags = flags;
 }
Esempio n. 4
0
        public override void CopyTo(T[] array, int arrayIndex)
        {
            MutableModel model = this.obj.MModel;
            GreenList    green = this.GetGreen(true);

            for (int i = 0; i < green.Count && arrayIndex + i < array.Length; i++)
            {
                array[arrayIndex + i] = (T)model.ToRedValue(green[i], this.obj.MId);
            }
        }
Esempio n. 5
0
        public override IEnumerator <T> GetEnumerator()
        {
            MutableModel model = this.obj.MModel;
            GreenList    green = this.GetGreen(true);

            foreach (var greenValue in green)
            {
                yield return((T)model.ToRedValue(greenValue, this.obj.MId));
            }
        }
        public MutableObjectBase CreateMutable(MutableModel model, bool weakReference = false, bool makeCreated = true)
        {
            var obj = model.CreateObject(this.CreateObjectId(), false);

            obj.MCallInit();
            if (makeCreated)
            {
                obj.MMakeCreated();
            }
            return(obj);
        }
Esempio n. 7
0
 public ModelFactory(MutableModel model, IMetaModel metaModel, ModelFactoryFlags flags = ModelFactoryFlags.None)
     : base(model, flags)
 {
     if (metaModel == null)
     {
         throw new ArgumentNullException(nameof(metaModel));
     }
     _metaModel          = metaModel;
     _metaModelAssembly  = metaModel.GetType().Assembly;
     _metaModelNamespace = metaModel.Namespace + ".";
     _descriptors        = new ConcurrentDictionary <string, ModelObjectDescriptor>();
 }
Esempio n. 8
0
 protected MutableObjectBase(ObjectId id, MutableModel model, bool creating)
 {
     if (id == null)
     {
         throw new ArgumentNullException(nameof(id));
     }
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     this.id       = id;
     this.model    = model;
     this.creating = creating;
 }
Esempio n. 9
0
 public void AddReference(MutableModel reference)
 {
     if (reference.ModelGroup != null)
     {
         GreenModelGroup gmg = reference.ModelGroup.Green;
         foreach (var greenReference in gmg.References)
         {
             this.AddReference(greenReference.Value);
         }
         foreach (var greenModel in gmg.Models)
         {
             this.AddReference(greenModel.Value);
         }
     }
     else
     {
         this.AddReference(reference.Green);
     }
 }
Esempio n. 10
0
        public MutableModel CreateModel(string name = null, ModelVersion version = default)
        {
            ModelId      mid   = new ModelId();
            MutableModel model = new MutableModel(mid, this, false, null);

            this.models.Add(mid, model);
            GreenModel greenModel;
            GreenModelUpdateContext ctx = null;

            try
            {
                do
                {
                    ctx        = this.BeginUpdate();
                    greenModel = ctx.Updater.CreateModel(mid, name, version);
                } while (!this.EndUpdate(ctx));
            }
            finally
            {
                this.FinalizeUpdate(ctx);
            }
            return(model);
        }
Esempio n. 11
0
        public MutableModel ToMutable(bool createNew = false)
        {
            MutableModel result = null;

            if (!createNew)
            {
                if (this.mutableModel.TryGetTarget(out result) && result != null)
                {
                    return(result);
                }
            }
            MutableModel newModel = null;

            if (this.group != null)
            {
                MutableModelGroup mutableGroup = this.group.ToMutable(createNew);
                newModel = mutableGroup.GetModel(this.green.Id);
            }
            else
            {
                newModel = new MutableModel(this.green, this);
            }
            return(newModel);
        }
Esempio n. 12
0
 public ModelFactory(MutableModel model, ModelFactoryFlags flags = ModelFactoryFlags.None)
     : base(model, flags)
 {
 }
Esempio n. 13
0
        public MutableObject ToMutable()
        {
            MutableModel mutableModel = this.model.ToMutable();

            return(mutableModel.GetObject(this));
        }
Esempio n. 14
0
 public void AddModel(MutableModel model)
 {
     // TODO
     throw new NotImplementedException();
 }
Esempio n. 15
0
 internal ImmutableModelListFromGreenListMutable(GreenList green, MutableModel model, ObjectId context)
 {
     this.green   = green;
     this.model   = model;
     this.context = context;
 }
Esempio n. 16
0
 internal ImmutableModel(ModelId id, ImmutableModelGroup group, GreenModel green, bool readOnly, MutableModel mutableModel)
 {
     this.id           = id;
     this.group        = group;
     this.green        = green;
     this.readOnly     = readOnly;
     this.objects      = null;
     this.mutableModel = new WeakReference <MutableModel>(mutableModel);
 }
Esempio n. 17
0
 internal ImmutableModelListFromObjectIdListMutable(ImmutableList <ObjectId> green, MutableModel model)
 {
     this.green = green;
     this.model = model;
 }
Esempio n. 18
0
 internal static ImmutableModelList <T> FromGreenList(GreenList green, MutableModel model, ObjectId context)
 {
     return(new ImmutableModelListFromGreenListMutable <T>(green, model, context));
 }
Esempio n. 19
0
 public abstract MutableObjectBase CreateMutable(MutableModel model, bool creating);
Esempio n. 20
0
 internal static ImmutableModelList <T> FromObjectIdList(ImmutableList <ObjectId> green, MutableModel model)
 {
     return(new ImmutableModelListFromObjectIdListMutable <T>(green, model));
 }