Defines common features and interfaces for SerializationMethodGeneratorManager.
        protected override AssemblyBuilderEmittingContext CreateCodeGenerationContextForSerializerCreation(SerializationContext context)
        {
            string serializerTypeName, serializerTypeNamespace;

            DefaultSerializerNameResolver.ResolveTypeName(
                true,
                typeof(TObject),
                this.GetType().Namespace,
                out serializerTypeName,
                out serializerTypeNamespace
                );
            var spec =
                new SerializerSpecification(
                    typeof(TObject),
                    CollectionTraitsOfThis,
                    serializerTypeName,
                    serializerTypeNamespace
                    );

            return
                (new AssemblyBuilderEmittingContext(
                     context,
                     typeof(TObject),
                     () => SerializationMethodGeneratorManager.Get().CreateEmitter(spec, BaseClass, EmitterFlavor.FieldBased),
                     () => SerializationMethodGeneratorManager.Get().CreateEnumEmitter(context, spec, EmitterFlavor.FieldBased)
                     ));
        }
Exemplo n.º 2
0
        public static SerializerEmitter CreateTupleSerializerCore(Type tupleType, EmitterFlavor emitterFlavor)
        {
            Contract.Requires(tupleType != null);
            Contract.Ensures(Contract.Result <SerializerEmitter>() != null);

            var emitter   = SerializationMethodGeneratorManager.Get().CreateEmitter(tupleType, emitterFlavor);
            var itemTypes = TupleItems.GetTupleItemTypes(tupleType);

            CreateTuplePack(
                emitter,
                tupleType,
                itemTypes,
                (il, collection) =>
            {
                il.EmitAnyLdarg(2);
                il.EmitAnyStloc(collection);
            }
                );
            CreateTupleUnpack(
                emitter,
                itemTypes
                );

            return(emitter);
        }
Exemplo n.º 3
0
        public AssemblyBuilderCodeGenerationContext(SerializationContext context, AssemblyBuilder assemblyBuilder)
        {
            this._context         = context;
            this._assemblyBuilder = assemblyBuilder;

            DefaultSerializationMethodGeneratorManager.SetUpAssemblyBuilderAttributes(assemblyBuilder, false);
            this._generatorManager = SerializationMethodGeneratorManager.Get(assemblyBuilder);
        }
		public AssemblyBuilderCodeGenerationContext( SerializationContext context, AssemblyBuilder assemblyBuilder )
		{
			this._context = context;
			this._assemblyBuilder = assemblyBuilder;

			DefaultSerializationMethodGeneratorManager.SetUpAssemblyBuilderAttributes( assemblyBuilder, false );
			this._generatorManager = SerializationMethodGeneratorManager.Get( assemblyBuilder );
		}
Exemplo n.º 5
0
        internal static void Refresh()
        {
#if !SILVERLIGHT
            _canCollect = Create(false, true, null);
#if !NETSTANDARD1_1 && !NETSTANDARD1_3
            _canDump = Create(true, false, null);
#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3
#endif // !SILVERLIGHT
            _fast = Create(false, false, null);
        }
Exemplo n.º 6
0
 protected override AssemblyBuilderEmittingContext CreateCodeGenerationContextForSerializerCreation(SerializationContext context)
 {
     return
         (new AssemblyBuilderEmittingContext(
              context,
              typeof(TObject),
              () => SerializationMethodGeneratorManager.Get().CreateEmitter(typeof(TObject), EmitterFlavor.FieldBased),
              () => SerializationMethodGeneratorManager.Get().CreateEnumEmitter(typeof(TObject), EmitterFlavor.FieldBased)
              ));
 }
        internal static void Refresh()
        {
#if !SILVERLIGHT
            _canCollect = new SerializationMethodGeneratorManager(false, true, null);
#if !NETSTANDARD1_1 && !NETSTANDARD1_3
            _canDump = new SerializationMethodGeneratorManager(true, false, null);
#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3
#endif // !SILVERLIGHT
            _fast = new SerializationMethodGeneratorManager(false, false, null);
        }
		protected override DynamicMethodEmittingContext CreateCodeGenerationContextForSerializerCreation( SerializationContext context )
		{
			return
				new DynamicMethodEmittingContext(
					context,
					typeof( TObject ),
					() => SerializationMethodGeneratorManager.Get().CreateEmitter( typeof( TObject ), BaseClass, EmitterFlavor.ContextBased ),
					() => SerializationMethodGeneratorManager.Get().CreateEnumEmitter( typeof( TObject ), EmitterFlavor.ContextBased )
				);
		}
		public AssemblyBuilderCodeGenerationContext( SerializationContext context, AssemblyBuilder assemblyBuilder, SerializerAssemblyGenerationConfiguration configuration )
		{
			this._context = context;
			this._assemblyBuilder = assemblyBuilder;

			DefaultSerializationMethodGeneratorManager.SetUpAssemblyBuilderAttributes( assemblyBuilder, false );
			this._generatorManager = SerializationMethodGeneratorManager.Get( assemblyBuilder );
			this._directory = configuration.OutputDirectory;
			this._generatedSerializers = new List<SerializerSpecification>();
		}
Exemplo n.º 10
0
        public AssemblyBuilderCodeGenerationContext(SerializationContext context, AssemblyBuilder assemblyBuilder, SerializerAssemblyGenerationConfiguration configuration)
        {
            this._context         = context;
            this._assemblyBuilder = assemblyBuilder;

            DefaultSerializationMethodGeneratorManager.SetUpAssemblyBuilderAttributes(assemblyBuilder, false);
            this._generatorManager     = SerializationMethodGeneratorManager.Get(assemblyBuilder);
            this._directory            = configuration.OutputDirectory;
            this._generatedSerializers = new List <SerializerSpecification>();
        }
        public static SerializerEmitter CreateArraySerializerCore(Type targetType, EmitterFlavor emitterFlavor)
        {
            Contract.Requires(targetType != null);
            SerializerEmitter emitter          = SerializationMethodGeneratorManager.Get().CreateEmitter(targetType, emitterFlavor);
            CollectionTraits  collectionTraits = targetType.GetCollectionTraits();

            CreatePackArrayProceduresCore(targetType, emitter, collectionTraits);
            CreateUnpackArrayProceduresCore(targetType, emitter, collectionTraits);
            return(emitter);
        }
Exemplo n.º 12
0
        public static SerializerEmitter CreateArraySerializerCore(SerializationContext context, Type targetType, EmitterFlavor emitterFlavor)
        {
            Contract.Requires(targetType != null);
            Contract.Ensures(Contract.Result <SerializerEmitter>() != null);

            var emitter = SerializationMethodGeneratorManager.Get().CreateEmitter(targetType, emitterFlavor);
            var traits  = targetType.GetCollectionTraits();

            CreatePackArrayProceduresCore(targetType, emitter, traits);
            CreateUnpackArrayProceduresCore(context, targetType, emitter, traits);
            return(emitter);
        }
Exemplo n.º 13
0
        public static SerializerEmitter CreateMapSerializerCore(Type targetType, EmitterFlavor emitterFlavor)
        {
            Contract.Requires(targetType != null);
            Contract.Ensures(Contract.Result <SerializerEmitter>() != null);


            var emitter = SerializationMethodGeneratorManager.Get().CreateEmitter(targetType, emitterFlavor);
            var traits  = targetType.GetCollectionTraits();

            CreateMapPack(
                targetType,
                emitter,
                traits
                );
            CreateMapUnpack(
                targetType,
                emitter,
                traits
                );

            return(emitter);
        }
 protected override DynamicMethodEmittingContext CreateCodeGenerationContextForSerializerCreation(SerializationContext context)
 {
     return
         (new DynamicMethodEmittingContext(
              context,
              typeof(TObject),
              () =>
              SerializationMethodGeneratorManager.Get()
              .CreateEmitter(
                  SerializerSpecification.CreateAnonymous(typeof(TObject), CollectionTraitsOfThis),
                  BaseClass,
                  EmitterFlavor.ContextBased
                  ),
              () =>
              SerializationMethodGeneratorManager.Get()
              .CreateEnumEmitter(
                  context,
                  SerializerSpecification.CreateAnonymous(typeof(TObject), CollectionTraitsOfThis),
                  EmitterFlavor.ContextBased
                  )
              ));
 }
Exemplo n.º 15
0
 /// <summary>
 ///		Initializes a new instance of the <see cref="EmittingSerializerBuilder&lt;TObject&gt;"/> class.
 /// </summary>
 /// <param name="context">The <see cref="SerializationContext"/>.</param>
 protected EmittingSerializerBuilder(SerializationContext context)
     : base(context)
 {
     this._emitterFlavor    = context.EmitterFlavor;
     this._generatorManager = SerializationMethodGeneratorManager.Get(context.GeneratorOption);
 }
		internal static void Refresh()
		{
#if !SILVERLIGHT
			_canCollect = new SerializationMethodGeneratorManager( false, true, null );
#if !NETSTANDARD1_1 && !NETSTANDARD1_3
			_canDump = new SerializationMethodGeneratorManager( true, false, null );
#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3
#endif // !SILVERLIGHT
			_fast = new SerializationMethodGeneratorManager( false, false, null );
		}