public MutableObject ToMutable(MutableModel mutableModel) { if (mutableModel == null) { throw new ArgumentNullException(nameof(mutableModel)); } return(mutableModel.GetObject(this)); }
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); }
public ModelFactoryBase(MutableModel model, ModelFactoryFlags flags = ModelFactoryFlags.None) { if (model == null) { throw new ArgumentNullException(nameof(model)); } this.model = model; this.flags = flags; }
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); } }
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); }
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>(); }
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; }
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); } }
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); }
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); }
public ModelFactory(MutableModel model, ModelFactoryFlags flags = ModelFactoryFlags.None) : base(model, flags) { }
public MutableObject ToMutable() { MutableModel mutableModel = this.model.ToMutable(); return(mutableModel.GetObject(this)); }
public void AddModel(MutableModel model) { // TODO throw new NotImplementedException(); }
internal ImmutableModelListFromGreenListMutable(GreenList green, MutableModel model, ObjectId context) { this.green = green; this.model = model; this.context = context; }
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 ImmutableModelListFromObjectIdListMutable(ImmutableList <ObjectId> green, MutableModel model) { this.green = green; this.model = model; }
internal static ImmutableModelList <T> FromGreenList(GreenList green, MutableModel model, ObjectId context) { return(new ImmutableModelListFromGreenListMutable <T>(green, model, context)); }
public abstract MutableObjectBase CreateMutable(MutableModel model, bool creating);
internal static ImmutableModelList <T> FromObjectIdList(ImmutableList <ObjectId> green, MutableModel model) { return(new ImmutableModelListFromObjectIdListMutable <T>(green, model)); }