Exemplo n.º 1
0
        private void MaybeSerializeValue(SerializationInfo info, FieldAccessor field, dynamic fieldValue,
                                         dynamic fieldType)
        {
            if (fieldValue is null)
            {
                info.AddValue(field.name, null);
                return;
            }

            var  acc   = GetAccessor(field);
            bool found = GetRoot()._objsCache.TryGetValue(fieldValue, out RuntimeClassSerializer rcs);

            if (found)
            {
                rcs._nodeAccs.Add(acc);
                info.AddValue(field.name, null);
            }
            else
            {
                var newRcs = new RuntimeClassSerializer
                                 (fieldType, fieldValue, this, field);
                GetRoot()._objs.Add(newRcs);
                GetRoot()._objsCache.Add(fieldValue, newRcs);
                info.AddValue(field.name, newRcs);
            }
        }
Exemplo n.º 2
0
 private RuntimeClassSerializer(Type bclass, object bobject, RuntimeClassSerializer parent,
                                FieldAccessor fieldAccessor)
 {
     this._type      = bclass;
     this.obj        = bobject;
     this._parent    = parent;
     this._fromField = fieldAccessor;
 }
Exemplo n.º 3
0
        private MethodInfoWrapper(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }
            Contract.EndContractBlock();

            var rcs = new RuntimeClassSerializer(info, context);

            MethodInfo = (MethodInfo)rcs.obj;
        }
Exemplo n.º 4
0
        /// <summary>
        /// serialize a RuntimeMethodInfo object
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }
            Contract.EndContractBlock();

            var rcs = new RuntimeClassSerializer
                          (MethodInfo.GetType(), MethodInfo);

            ((ISerializable)rcs).GetObjectData(info, context);
        }