Пример #1
0
 public MutableModel GetReference(ModelId mid)
 {
     if (mid == null || !this.Green.References.ContainsKey(mid))
     {
         return(null);
     }
     return(this.GetExistingReference(mid));
 }
Пример #2
0
 public MutableModel GetModel(ModelId mid)
 {
     if (mid == null || !this.Green.Models.ContainsKey(mid))
     {
         return(null);
     }
     return(this.GetExistingModel(mid));
 }
Пример #3
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);
 }
Пример #4
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);
 }
Пример #5
0
 internal MutableModel(GreenModel green, ImmutableModel immutableModel)
 {
     this.id             = green.Id;
     this.group          = null;
     this.green          = green;
     this.updater        = new ThreadLocal <GreenModelUpdater>();
     this.readOnly       = false;
     this.objects        = new ConditionalWeakTable <ObjectId, MutableObject>();
     this.immutableModel = new WeakReference <ImmutableModel>(immutableModel);
 }
Пример #6
0
 internal MutableModel(ModelId id, MutableModelGroup group, bool readOnly, ImmutableModel immutableModel)
 {
     this.id             = id;
     this.group          = group;
     this.green          = null;
     this.updater        = null;
     this.readOnly       = readOnly;
     this.objects        = null;
     this.immutableModel = new WeakReference <ImmutableModel>(immutableModel);
 }
Пример #7
0
        private ImmutableModel GetImmutableReference(ModelId mid)
        {
            ImmutableModelGroup result;

            if (this.immutableModelGroup.TryGetTarget(out result) && result != null && result.Green == this.Green)
            {
                return(result.GetReference(mid));
            }
            return(null);
        }
Пример #8
0
        private MutableModel GetMutableModel(ModelId mid)
        {
            MutableModelGroup result;

            if (this.mutableModelGroup.TryGetTarget(out result) && result != null && result.Green == this.Green)
            {
                return(result.GetModel(mid));
            }
            return(null);
        }
Пример #9
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);
        }
Пример #10
0
 internal MutableObject GetExistingModelObject(ModelId mid, ObjectId oid)
 {
     return(this.objects.GetValue(oid, key => key.CreateMutable(this.GetExistingModel(mid), false)));
 }
Пример #11
0
 private MutableModel GetExistingModel(ModelId mid)
 {
     return(this.models.GetValue(mid, key => new MutableModel(key, this, false, null)));
 }
Пример #12
0
 private MutableModel GetExistingReference(ModelId mid)
 {
     return(this.models.GetValue(mid, key => new MutableModel(key, this, true, null)));
 }
Пример #13
0
 private ImmutableModel GetExistingModel(ModelId mid)
 {
     return(this.models.GetValue(mid, key => new ImmutableModel(key, this, this.Green.Models.GetValueOrDefault(key), false, this.GetMutableReference(key))));
 }
Пример #14
0
 internal ImmutableObjectBase GetExistingModelObject(ModelId mid, ObjectId sid)
 {
     return(this.objects.GetValue(sid, key => key.CreateImmutable(this.GetExistingModel(mid))));
 }