Example #1
0
 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);
 }
Example #2
0
        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));
            }
        }
Example #3
0
        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;
        }
Example #4
0
 protected internal void SetSlot(MValue newSlot, MValue oldSlot)
 {
     if (_slot == oldSlot)
     {
         _slot = newSlot;
         if (newSlot == null)
         {
             Parent = null;
         }
     }
 }
Example #5
0
 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;
     }
 }
Example #6
0
        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);
        }
Example #7
0
 public virtual void InitAsCopyOf(MCollection original, bool isMutable)
 {
     Debug.Assert(Context == MContext.Null);
     Context   = original.Context;
     IsMutable = MutableChildren = isMutable;
 }
Example #8
0
 public MDict(MValue mv, MCollection parent)
 {
     InitInSlot(mv, parent);
 }
Example #9
0
 public void InitInSlot(MValue mv, MCollection parent)
 {
     InitInSlot(mv, parent, parent?.MutableChildren == true);
 }