public ImmutableObject ToImmutable(ImmutableModel immutableModel) { if (immutableModel == null) { throw new ArgumentNullException(nameof(immutableModel)); } return(immutableModel.GetObject(this)); }
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); }
protected ImmutableObjectBase(ObjectId id, ImmutableModel model) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } this.id = id; this.model = model; }
public void AddReference(ImmutableModel 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); } }
public ImmutableModel ToImmutable(bool evaluateLazyValues = true, CancellationToken cancellationToken = default) { ImmutableModel result; if (this.group != null) { ImmutableModelGroup immutableGroup = this.group.ToImmutable(evaluateLazyValues, cancellationToken); if (immutableGroup != null) { if (this.readOnly) { result = immutableGroup.GetReference(this.id); } else { result = immutableGroup.GetModel(this.id); } return(result); } } else { if (evaluateLazyValues) { this.EvaluateLazyValues(cancellationToken); } GreenModel currentGreen = this.Green; if (this.immutableModel.TryGetTarget(out result) && result != null && result.Green == currentGreen) { return(result); } else { result = new ImmutableModel(currentGreen, this); Interlocked.Exchange(ref this.immutableModel, new WeakReference <ImmutableModel>(result)); return(result); } } return(null); }
public abstract ImmutableObjectBase CreateImmutable(ImmutableModel model);
internal static ImmutableModelList <T> FromGreenSingleValue(object value, ImmutableModel model, ObjectId context) { return(new ImmutableModelListFromGreenSingle <T>(value, model, context)); }
internal static ImmutableModelList <T> FromObjectIdList(ImmutableList <ObjectId> green, ImmutableModel model) { return(new ImmutableModelListFromObjectIdListImmutable <T>(green, model)); }
internal static ImmutableModelList <T> FromGreenList(GreenList green, ImmutableModel model, ObjectId context) { return(new ImmutableModelListFromGreenListImmutable <T>(green, model, context)); }
internal ImmutableModelListFromGreenSingle(object greenValue, ImmutableModel model, ObjectId context) { this.greenValue = greenValue; this.model = model; this.context = context; }
internal ImmutableModelListFromObjectIdListImmutable(ImmutableList <ObjectId> green, ImmutableModel model) { this.green = green; this.model = model; }
internal ImmutableModelListFromGreenListImmutable(GreenList green, ImmutableModel model, ObjectId context) { this.green = green; this.model = model; this.context = context; }
public void AddModel(ImmutableModel model) { // TODO throw new NotImplementedException(); }
internal ImmutableObjectBase CreateImmutable(ImmutableModel model) { return(this.CreateObjectId().CreateImmutable(model)); }
public ImmutableObject ToImmutable() { ImmutableModel immutableModel = this.model.ToImmutable(); return(immutableModel.GetObject(this)); }