public override bool Contains(T item) { GreenList green = this.GetGreen(true); object greenItem = this.obj.MModel.ToGreenValue(item); return(green.Contains(greenItem)); }
public override int IndexOf(T item) { GreenList green = this.GetGreen(true); object greenItem = this.obj.MModel.ToGreenValue(item); return(green.IndexOf(item)); }
internal GreenList GetGreenList(ObjectId oid, ModelProperty property, bool lazyEval) { Debug.Assert(property.IsCollection); object value = null; if (!lazyEval) { return(this.GetGreenList(oid, property)); } GreenModelUpdateContext ctx = null; try { var slot = oid.Descriptor.GetSlot(property); do { ctx = this.BeginUpdate(); value = ctx.Updater.GetValue(this.id, oid, slot, true); } while (!this.EndUpdate(ctx)); GreenList result = value as GreenList; if (result == null) { result = property.IsUnique ? GreenList.EmptyUnique : GreenList.EmptyNonUnique; } return(result); } finally { this.FinalizeUpdate(ctx); } }
private GreenList CollectBases(ObjectId oid) { GreenList result = GreenList.EmptyUnique; foreach (var prop in this.MProperties(oid)) { if (prop.IsBaseScope) { if (prop.IsCollection) { var items = this.GetGreenValue(oid, prop) as GreenList; if (items != null) { result = result.AddRange(items); } } else { var item = this.GetGreenValue(oid, prop); result = result.Add(item); } } } return(result); }
internal ImmutableModelList <ImmutableObject> MGetMembers(ObjectId oid) { GreenList result = GreenList.EmptyUnique; foreach (var prop in this.MProperties(oid)) { if (prop.CanResolve) { if (prop.IsCollection) { var items = this.GetGreenValue(oid, prop) as GreenList; if (items != null) { result = result.AddRange(items); } } else { var item = this.GetGreenValue(oid, prop); result = result.Add(item); } } } return(ImmutableModelList <ImmutableObject> .FromGreenList(result, this, oid)); }
internal ImmutableModelList <ImmutableObject> MGetBases(ObjectId oid) { GreenList result = this.CollectBases(oid); result = result.Remove(oid); return(ImmutableModelList <ImmutableObject> .FromGreenList(result, this, oid)); }
internal ImmutableModelList <ImmutableObject> MGetAllBases(ObjectId oid) { GreenList result = GreenList.EmptyUnique; this.CollectAllBases(oid, ref result); result = result.Remove(oid); return(ImmutableModelList <ImmutableObject> .FromGreenList(result, this, oid)); }
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 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 T this[int index] { get { GreenList green = this.GetGreen(false); return((T)this.obj.MModel.ToRedValue(green[index], this.obj.MId)); } set { this.obj.MModel.ReplaceItem(this.obj.MId, this.slot.EffectiveProperty, index, value, this.obj.MIsBeingCreated); } }
private void CollectAllBases(ObjectId oid, ref GreenList result) { if (oid == null) { return; } var oldResult = result; result = result.Add(oid); if (result == oldResult) { return; } var bases = this.CollectBases(oid); foreach (var item in bases) { this.CollectAllBases(item as ObjectId, ref result); } }
internal static ImmutableModelList <T> FromGreenList(GreenList green, MutableModel model, ObjectId context) { return(new ImmutableModelListFromGreenListMutable <T>(green, model, context)); }
internal ImmutableModelListFromGreenListMutable(GreenList green, MutableModel model, ObjectId context) { this.green = green; this.model = model; this.context = context; }