Пример #1
0
        protected sealed override void ResetCore(Type targetType, Type baseClass)
        {
            // Note: baseClass is always null this class hiearchy.
            this.Packer         = ILConstruct.Argument(1, typeof(Packer), "packer");
            this.PackToTarget   = ILConstruct.Argument(2, targetType, "objectTree");
            this.Unpacker       = ILConstruct.Argument(1, typeof(Unpacker), "unpacker");
            this.UnpackToTarget = ILConstruct.Argument(2, targetType, "collection");
            var traits = targetType.GetCollectionTraits();

            if (traits.ElementType != null)
            {
                this.CollectionToBeAdded = ILConstruct.Argument(1, targetType, "collection");
                this.ItemToAdd           = ILConstruct.Argument(2, traits.ElementType, "item");
                if (traits.DetailedCollectionType == CollectionDetailedKind.GenericDictionary
#if !NETFX_35 && !UNITY && !NETFX_40 && !SILVERLIGHT
                    || traits.DetailedCollectionType == CollectionDetailedKind.GenericReadOnlyDictionary
#endif // !NETFX_35 && !UNITY && !NETFX_40 && !SILVERLIGHT
                    )
                {
                    this.KeyToAdd   = ILConstruct.Argument(2, traits.ElementType.GetGenericArguments()[0], "key");
                    this.ValueToAdd = ILConstruct.Argument(3, traits.ElementType.GetGenericArguments()[1], "value");
                }
                this.InitialCapacity = ILConstruct.Argument(1, typeof(int), "initialCapacity");
            }
            this._emitter     = null;
            this._enumEmitter = null;
        }
Пример #2
0
 /// <summary>
 ///		Resets internal states for specified target type.
 /// </summary>
 /// <param name="targetType">Type of the serialization target.</param>
 protected sealed override void ResetCore(Type targetType)
 {
     this.Packer         = ILConstruct.Argument(1, typeof(Packer), "packer");
     this.PackToTarget   = ILConstruct.Argument(2, targetType, "objectTree");
     this.Unpacker       = ILConstruct.Argument(1, typeof(Unpacker), "unpacker");
     this.UnpackToTarget = ILConstruct.Argument(2, targetType, "collection");
     this._emitter       = null;
     this._enumEmitter   = null;
 }
Пример #3
0
        protected sealed override void ResetCore(Type targetType, Type baseClass)
        {
            // Note: baseClass is always null this class hiearchy.
            this.Packer         = ILConstruct.Argument(1, typeof(Packer), "packer");
            this.PackToTarget   = ILConstruct.Argument(2, targetType, "objectTree");
            this.Unpacker       = ILConstruct.Argument(1, typeof(Unpacker), "unpacker");
            this.UnpackToTarget = ILConstruct.Argument(2, targetType, "collection");
            var traits = targetType.GetCollectionTraits();

            if (traits.ElementType != null)
            {
                this.CollectionToBeAdded = ILConstruct.Argument(1, targetType, "collection");
                this.ItemToAdd           = ILConstruct.Argument(2, traits.ElementType, "item");
                this.InitialCapacity     = ILConstruct.Argument(1, typeof(int), "initialCapacity");
            }
            this._emitter     = null;
            this._enumEmitter = null;
        }