protected override void BuildSerializerCodeCore(ISerializerCodeGenerationContext context, Type concreteType, PolymorphismSchema itemSchema)
        {
            var asAssemblyBuilderCodeGenerationContext = context as AssemblyBuilderCodeGenerationContext;

            if (asAssemblyBuilderCodeGenerationContext == null)
            {
                throw new ArgumentException(
                          "'context' was not created with CreateGenerationContextForCodeGeneration method.",
                          "context"
                          );
            }

            var emittingContext =
                asAssemblyBuilderCodeGenerationContext.CreateEmittingContext(
                    typeof(TObject),
                    CollectionTraitsOfThis,
                    BaseClass
                    );

            if (!typeof(TObject).GetIsEnum())
            {
                this.BuildSerializer(emittingContext, concreteType, itemSchema);
                // Finish type creation, and discard returned ctor.
                emittingContext.Emitter.CreateConstructor <TObject>();
            }
            else
            {
                this.BuildEnumSerializer(emittingContext);
                // Finish type creation, and discard returned ctor.
                emittingContext.EnumEmitter.CreateConstructor <TObject>();
            }
        }
Esempio n. 2
0
        /// <summary>
        ///		Builds the serializer code using specified code generation context.
        /// </summary>
        /// <param name="context">
        ///		The <see cref="ISerializerCodeGenerationContext"/> which holds configuration and stores generated code constructs.
        /// </param>
        /// <param name="concreteType">The substitution type if <typeparamref name="TObject"/> is abstract type. <c>null</c> when <typeparamref name="TObject"/> is not abstract type.</param>
        /// <param name="itemSchema">The schema which contains schema for collection items, dictionary keys, or tuple items. This value must not be <c>null</c>.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="context"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///		This class does not support code generation.
        /// </exception>
        public void BuildSerializerCode(ISerializerCodeGenerationContext context, Type concreteType, PolymorphismSchema itemSchema)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.BuildSerializerCodeCore(context, concreteType, itemSchema);
        }
Esempio n. 3
0
        /// <summary>
        ///		Builds the serializer code using specified code generation context.
        /// </summary>
        /// <param name="context">
        ///		The <see cref="ISerializerCodeGenerationContext"/> which holds configuration and stores generated code constructs.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="context"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///		This class does not support code generation.
        /// </exception>
        /// <remarks>
        ///		This method will not do anything when <see cref="ISerializerCodeGenerationContext.BuiltInSerializerExists"/> returns <c>true</c> for <typeparamref name="TObject"/>.
        /// </remarks>
        public void BuildSerializerCode(ISerializerCodeGenerationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (context.BuiltInSerializerExists(typeof(TObject)))
            {
                // nothing to do.
                return;
            }

            this.BuildSerializerCodeCore(context);
        }
        /// <summary>
        ///		Builds the serializer code using specified code generation context.
        /// </summary>
        /// <param name="context">
        ///		The <see cref="ISerializerCodeGenerationContext"/> which holds configuration and stores generated code constructs.
        /// </param>
        /// <param name="concreteType">The substitution type if <typeparamref name="TObject"/> is abstract type. <c>null</c> when <typeparamref name="TObject"/> is not abstract type.</param>
        /// <param name="itemSchema">The schema which contains schema for collection items, dictionary keys, or tuple items. This value must not be <c>null</c>.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="context"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///		This class does not support code generation.
        /// </exception>
        /// <remarks>
        ///		This method will not do anything when <see cref="ISerializerCodeGenerationContext.BuiltInSerializerExists"/> returns <c>true</c> for <typeparamref name="TObject"/>.
        /// </remarks>
        public void BuildSerializerCode(ISerializerCodeGenerationContext context, Type concreteType, PolymorphismSchema itemSchema)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (context.BuiltInSerializerExists(typeof(TObject)))
            {
                // nothing to do.
                return;
            }

            this.BuildSerializerCodeCore(context, concreteType, itemSchema);
        }
Esempio n. 5
0
        protected override void BuildSerializerCodeCore(ISerializerCodeGenerationContext context)
        {
            var asAssemblyBuilderCodeGenerationContext = context as AssemblyBuilderCodeGenerationContext;

            if (asAssemblyBuilderCodeGenerationContext == null)
            {
                throw new ArgumentException(
                          "'context' was not created with CreateGenerationContextForCodeGeneration method.",
                          "context"
                          );
            }

            var emittingContext =
                asAssemblyBuilderCodeGenerationContext.CreateEmittingContext(
                    typeof(TObject)
                    );

            this.BuildSerializer(emittingContext);
            // Finish type creation, and discard returned ctor.
            emittingContext.Emitter.CreateConstructor <TObject>();
        }
Esempio n. 6
0
 /// <summary>
 ///		In derived class, builds the serializer code using specified code generation context.
 /// </summary>
 /// <param name="context">
 ///		The <see cref="ISerializerCodeGenerationContext"/> which holds configuration and stores generated code constructs.
 ///		This value will not be <c>null</c>.
 /// </param>
 /// <param name="concreteType">The substitution type if <typeparamref name="TObject"/> is abstract type. <c>null</c> when <typeparamref name="TObject"/> is not abstract type.</param>
 /// <param name="itemSchema">The schema which contains schema for collection items, dictionary keys, or tuple items. This value must not be <c>null</c>.</param>
 /// <exception cref="NotSupportedException">
 ///		This class does not support code generation.
 /// </exception>
 protected virtual void BuildSerializerCodeCore(ISerializerCodeGenerationContext context, Type concreteType, PolymorphismSchema itemSchema)
 {
     throw new NotSupportedException();
 }
Esempio n. 7
0
 /// <summary>
 ///		In derived class, builds the serializer code using specified code generation context.
 /// </summary>
 /// <param name="context">
 ///		The <see cref="ISerializerCodeGenerationContext"/> which holds configuration and stores generated code constructs.
 ///		This value will not be <c>null</c>.
 /// </param>
 /// <exception cref="NotSupportedException">
 ///		This class does not support code generation.
 /// </exception>
 protected virtual void BuildSerializerCodeCore(ISerializerCodeGenerationContext context)
 {
     throw new NotSupportedException();
 }
 protected override void BuildSerializerCodeCore(ISerializerCodeGenerationContext context)
 {
     Contract.Requires(context != null);
 }
Esempio n. 9
0
 protected override void BuildSerializerCodeCore(ISerializerCodeGenerationContext context, Type concreteType, PolymorphismSchema itemSchema)
 {
     Contract.Requires(context != null);
 }