protected override void InitInSlot(MValue slot, MCollection parent, bool isMutable) { base.InitInSlot(slot, parent, isMutable); Debug.Assert(_dict == null); _dict = Native.FLValue_AsDict(slot.Value); Count = (int)Native.FLDict_Count(_dict); }
private static object ToObject(MValue mv, MCollection parent, ref bool cache) { var type = Native.FLValue_GetType(mv.Value); switch (type) { case FLValueType.Array: cache = true; return(parent?.MutableChildren == true ? new MutableArrayObject(mv, parent) : new ArrayObject(mv, parent)); case FLValueType.Dict: cache = true; var context = parent?.Context as DocContext; var flDict = Native.FLValue_AsDict(mv.Value); var subType = Native.FLValue_AsString(Native.FLDict_Get(flDict, Encoding.UTF8.GetBytes(ObjectTypeProperty))); var obj = CreateSpecialObject(subType, flDict, context); if (obj != null) { return(obj); } return(parent?.MutableChildren == true ? new MutableDictionaryObject(mv, parent) : new DictionaryObject(mv, parent)); default: return(FLSliceExtensions.ToObject(mv.Value)); } }
public override void InitAsCopyOf(MCollection original, bool isMutable) { base.InitAsCopyOf(original, isMutable); var d = original as MDict; _dict = d != null ? d._dict : null; _map = d?._map; Count = d?.Count ?? 0; }
protected internal void SetSlot(MValue newSlot, MValue oldSlot) { if (_slot == oldSlot) { _slot = newSlot; if (newSlot == null) { Parent = null; } } }
protected virtual void InitInSlot(MValue slot, MCollection parent, bool isMutable) { Debug.Assert(slot != null); Debug.Assert(Context == MContext.Null); _slot = slot; Parent = parent; IsMutable = isMutable; MutableChildren = isMutable; IsMutated = _slot.IsMutated; if (_slot.Value != null) { Context = Parent?.Context; } }
public object AsObject(MCollection parent) { if (NativeObject != null || Value == null) { return(NativeObject); } var cache = false; var obj = ToObject(this, parent, ref cache); if (cache) { NativeObject = obj; } return(obj); }
public virtual void InitAsCopyOf(MCollection original, bool isMutable) { Debug.Assert(Context == MContext.Null); Context = original.Context; IsMutable = MutableChildren = isMutable; }
public MDict(MValue mv, MCollection parent) { InitInSlot(mv, parent); }
public void InitInSlot(MValue mv, MCollection parent) { InitInSlot(mv, parent, parent?.MutableChildren == true); }