Exemplo n.º 1
0
        /// <summary>
        /// Create the entire (de)serialization code as C# code.
        /// </summary>
        public void Generate(CodeGenerator generator)
        {
            // Prepare type
            var typeDecl = new CodeTypeDeclaration(SerializationHelperTypeName);
            typeDecl.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            typeDecl.BaseTypes.Add("Dot42.Internal.SerializationHelperBase");

            // Generate method code
            typeSerializerBuilders.Values.ForEach(x => x.Generate(typeDecl, generator));
            typeDeserializerBuilders.Values.ForEach(x => x.Generate(typeDecl, generator));

            // Add type
            generator.Add(typeDecl);
        }
        /// <summary>
        /// Create the entire (de)serialization code as C# code.
        /// </summary>
        public void Generate(CodeGenerator generator)
        {
            // Prepare type
            var typeDecl = new CodeTypeDeclaration(SerializationHelperTypeName);

            typeDecl.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            typeDecl.BaseTypes.Add("Dot42.Internal.SerializationHelperBase");

            // Generate method code
            typeSerializerBuilders.Values.ForEach(x => x.Generate(typeDecl, generator));
            typeDeserializerBuilders.Values.ForEach(x => x.Generate(typeDecl, generator));

            // Add type
            generator.Add(typeDecl);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create the entire proxy class as C# code.
        /// </summary>
        public void Generate(CodeGenerator generator)
        {
            // Prepare type
            var typeDecl = new CodeTypeDeclaration(proxyTypeName);

            typeDecl.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            typeDecl.BaseTypes.Add("Dot42.Internal.WcfProxyBase");
            typeDecl.BaseTypes.Add(interfaceType.FullName);
            typeDecl.CustomAttributes.Add(new CodeAttributeDeclaration("Dot42.Include", new CodeAttributeArgument("ApplyToMembers", new CodePrimitiveExpression(true))));

            var methodDecl = new CodeConstructor();

            methodDecl.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            methodDecl.Parameters.Add(new CodeParameterDeclarationExpression(typeof(System.Uri), "baseAddress"));
            typeDecl.Members.Add(methodDecl);

            methodDecl.Statements.Add(new CodeAssignStatement(
                                          new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "baseAddress"), new CodeTypeReferenceExpression("baseAddress")));

            // Generate method code
            methodBuilders.ForEach(x => x.Generate(typeDecl, generator));

            generator.Add(typeDecl);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create the entire proxy class as C# code.
        /// </summary>
        public void Generate(CodeGenerator generator)
        {
            // Prepare type
            var typeDecl = new CodeTypeDeclaration(proxyTypeName);
            typeDecl.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            typeDecl.BaseTypes.Add("Dot42.Internal.WcfProxyBase");
            typeDecl.BaseTypes.Add(interfaceType.FullName);
            typeDecl.CustomAttributes.Add(new CodeAttributeDeclaration("Dot42.Include", new CodeAttributeArgument("ApplyToMembers", new CodePrimitiveExpression(true))));

            var methodDecl = new CodeConstructor();
            methodDecl.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            methodDecl.Parameters.Add(new CodeParameterDeclarationExpression(typeof(System.Uri), "baseAddress"));
            typeDecl.Members.Add(methodDecl);

            methodDecl.Statements.Add( new CodeAssignStatement(
                new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "baseAddress"), new CodeTypeReferenceExpression("baseAddress")));

            // Generate method code
            methodBuilders.ForEach(x => x.Generate(typeDecl, generator));

            generator.Add(typeDecl);
        }