public MutableModel GetReference(ModelId mid) { if (mid == null || !this.Green.References.ContainsKey(mid)) { return(null); } return(this.GetExistingReference(mid)); }
public MutableModel GetModel(ModelId mid) { if (mid == null || !this.Green.Models.ContainsKey(mid)) { return(null); } return(this.GetExistingModel(mid)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
internal MutableObject GetExistingModelObject(ModelId mid, ObjectId oid) { return(this.objects.GetValue(oid, key => key.CreateMutable(this.GetExistingModel(mid), false))); }
private MutableModel GetExistingModel(ModelId mid) { return(this.models.GetValue(mid, key => new MutableModel(key, this, false, null))); }
private MutableModel GetExistingReference(ModelId mid) { return(this.models.GetValue(mid, key => new MutableModel(key, this, true, null))); }
private ImmutableModel GetExistingModel(ModelId mid) { return(this.models.GetValue(mid, key => new ImmutableModel(key, this, this.Green.Models.GetValueOrDefault(key), false, this.GetMutableReference(key)))); }
internal ImmutableObjectBase GetExistingModelObject(ModelId mid, ObjectId sid) { return(this.objects.GetValue(sid, key => key.CreateImmutable(this.GetExistingModel(mid)))); }