/// <summary> /// Invokes all ICodeDecorator(s) in the decorators collection. /// </summary> public void ApplyDecorations(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { foreach (ICodeDecorator decorator in decorators) { decorator.Decorate(code, options); } }
/// <summary> /// Invokes all ICodeDecorator(s) in the decorators collection. /// </summary> public void ApplyDecorations(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { //string fileName = "C:\\Users\\rs239\\Documents\\NIEM\\temp\\Decorators.txt"; //StringWriter stringWriter = new StringWriter(); //stringWriter.WriteLine("Namespace = " + codeNamespace.Name); //stringWriter.WriteLine("___________________________________________"); //stringWriter.WriteLine(ctd.Name); //FileStream fs = File.Open(fileName, FileMode.Create, FileAccess.Write, FileShare.None); //StreamWriter writer = new StreamWriter(fs); //writer.Write(stringWriter); //writer.Flush(); foreach (ICodeDecorator decorator in decorators) { IMetadata metadataDecorator = decorator as IMetadata; if (metadataDecorator != null) { metadataDecorator.MetadataSet = this.metadataSet; } decorator.Decorate(code, options); } }
/// <summary> /// Invokes all ICodeDecorator(s) in the decorators collection. /// </summary> public void ApplyDecorations(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { foreach (ICodeDecorator decorator in decorators) { decorator.Decorate(code, options); } }
public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { if (options.GenerateTypedLists) { CollectionTypeGenerator generator = new CollectionTypeGenerator(new ListTypeProvider(), code); generator.Execute(); } }
public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { if (options.GenerateCollections) { CollectionTypeGenerator generator = new CollectionTypeGenerator(new CollectionTypeProvider(), code); generator.Execute(); } }
public CodeTypeReference CreateCollectionType(CodeTypeReference entityType, ExtendedCodeDomTree code) { Debug.Assert(entityType != null, "Argument entityType could not be null."); // Do not create a ByteCollection as this is not compatiable with base64Binary! if (entityType.BaseType == typeof(byte).FullName) return entityType; CodeTypeDeclaration collectionType = GenerateCollectionType(entityType); code.DataContracts.Add(new CodeTypeExtension(collectionType)); CodeTypeReference collectionRef = new CodeTypeReference(collectionType.Name); return collectionRef; }
public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { // Notify if we get any null references. Debug.Assert(code != null, "code parameter could not be null."); Debug.Assert(options != null, "options parameter could not be null."); // We apply this decorator only if this option is turned on. if (options.AdjustCasing) { // Initialize the state. this.code = code; this.options = options; DecorateInternal(); } }
public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { // Notify if we get any null references. Debug.Assert(code != null, "code parameter could not be null."); Debug.Assert(options != null, "options parameter could not be null."); // We apply this decorator only if this option is turned on. if (options.AdjustCasing) { // Initialize the state. this.code = code; this.options = options; DecorateInternal(); } }
public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { // Some validations to make debugging easier. Debug.Assert(code != null, "code parameter could not be null."); Debug.Assert(options != null, "options parameter could not be null."); // We execute this decorator only if we are generating the service side code. if (options.GenerateService) { // Initialize the state. this.code = code; this.options = options; CreateServiceType(); } }
public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { // Some validations to make debugging easier. Debug.Assert(code != null, "code parameter could not be null."); Debug.Assert(options != null, "options parameter could not be null."); // We execute this decorator only if we are generating the service side code. if (options.GenerateService) { // Initialize the state. this.code = code; this.options = options; CreateServiceType(); } }
public static PascalCaseConverterBase GetPascalCaseConverter(CodeTypeExtension typeExtension, ExtendedCodeDomTree code) { switch (typeExtension.Kind) { case CodeTypeKind.DataContract: return new DataContractConverter(typeExtension, code); case CodeTypeKind.MessageContract: return new MessageContractConverter(typeExtension, code); case CodeTypeKind.ServiceContract: return new ServiceContractConverter(typeExtension, code); case CodeTypeKind.ClientType: return new ClientTypeConverter(typeExtension, code); default: return null; } }
/// <summary> /// Executes the code generation workflow. /// </summary> public CodeWriterOutput GenerateCode(CodeGenerationOptions options) { // Step 1 - Parse the code generation options and create the code provider. codeGenerationOptions = CodeGenerationOptionsParser.ParseCodeGenerationOptions(options); CreateCodeProvider(); ExtendedCodeDomTree extendedCodeDomTree; MetadataSet metadataSet = null; if (options.GenerateDataContracts) { // Step 2 - Build the set of XML schemas. XmlSchemas schemas = MetadataFactory.GetXmlSchemas(codeGenerationOptions.MetadataResolverOptions); // Step 3 - Generate the data contract code and get the CodeNamespace. DataContractGenerator dataContractGenerator = new DataContractGenerator(schemas, codeGenerationOptions.PrimaryOptions, codeProvider); CodeNamespace codeNamespace = dataContractGenerator.GenerateCode(); // Step 4 - Wrap the CodeDOM in the custom object model. extendedCodeDomTree = new ExtendedCodeDomTree(codeNamespace, codeGenerationOptions.WriterOptions.Language, null); } else { // Step 2 - Build the service metadata. metadataSet = MetadataFactory.GetMetadataSet(codeGenerationOptions.MetadataResolverOptions); // Step 3 - Generate the client/service code and get the CodeNamespace. ClientServiceGenerator clientServiceGenerator = new ClientServiceGenerator(metadataSet, codeGenerationOptions.PrimaryOptions, codeProvider); CodeNamespace codeNamespace = clientServiceGenerator.GenerateCode(); // Step 4 - Wrap the CodeDOM in the custom object model. extendedCodeDomTree = new ExtendedCodeDomTree(codeNamespace, codeGenerationOptions.WriterOptions.Language, clientServiceGenerator.Configuration); } // Step 5 - Apply the code decorations. CodeDecorators decorators = new CodeDecorators(metadataSet); decorators.ApplyDecorations(extendedCodeDomTree, codeGenerationOptions.CustomOptions); // Step 6 - Restore the original CodeDOM. CodeNamespace cns = extendedCodeDomTree.UnwrapCodeDomTree(); // Step 6 - Finally, write out the code to physical files. return CodeWriter.Write(cns, extendedCodeDomTree.Configuration, codeGenerationOptions.WriterOptions, extendedCodeDomTree.TextFiles, codeProvider); }
/// <summary> /// Executes the code generation workflow. /// </summary> public CodeWriterOutput GenerateCode(CodeGenerationOptions options) { // Step 1 - Parse the code generation options and create the code provider. codeGenerationOptions = CodeGenerationOptionsParser.ParseCodeGenerationOptions(options); CreateCodeProvider(); ExtendedCodeDomTree extendedCodeDomTree; if (options.GenerateDataContracts) { // Step 2 - Build the set of XML schemas. XmlSchemas schemas = MetadataFactory.GetXmlSchemas(codeGenerationOptions.MetadataResolverOptions); // Step 3 - Generate the data contract code and get the CodeNamespace. DataContractGenerator dataContractGenerator = new DataContractGenerator(schemas, codeGenerationOptions.PrimaryOptions, codeProvider); CodeNamespace codeNamespace = dataContractGenerator.GenerateCode(); // Step 4 - Wrap the CodeDOM in the custom object model. extendedCodeDomTree = new ExtendedCodeDomTree(codeNamespace, codeGenerationOptions.WriterOptions.Language, null); } else { // Step 2 - Build the service metadata. MetadataSet metadataSet = MetadataFactory.GetMetadataSet(codeGenerationOptions.MetadataResolverOptions); // Step 3 - Generate the client/service code and get the CodeNamespace. ClientServiceGenerator clientServiceGenerator = new ClientServiceGenerator(metadataSet, codeGenerationOptions.PrimaryOptions, codeProvider); CodeNamespace codeNamespace = clientServiceGenerator.GenerateCode(); // Step 4 - Wrap the CodeDOM in the custom object model. extendedCodeDomTree = new ExtendedCodeDomTree(codeNamespace, codeGenerationOptions.WriterOptions.Language, clientServiceGenerator.Configuration); } // Step 5 - Apply the code decorations. CodeDecorators decorators = new CodeDecorators(); decorators.ApplyDecorations(extendedCodeDomTree, codeGenerationOptions.CustomOptions); // Step 6 - Restore the original CodeDOM. CodeNamespace cns = extendedCodeDomTree.UnwrapCodeDomTree(); // Step 6 - Finally, write out the code to physical files. return(CodeWriter.Write(cns, extendedCodeDomTree.Configuration, codeGenerationOptions.WriterOptions, extendedCodeDomTree.TextFiles, codeProvider)); }
public CodeTypeReference CreateCollectionType(CodeTypeReference entityType, ExtendedCodeDomTree code) { Debug.Assert(entityType != null, "Argument entityType could not be null."); // Do not create a ByteCollection as this is not compatiable with base64Binary! if (entityType.BaseType == typeof(byte).FullName) { return(entityType); } CodeTypeDeclaration collectionType = GenerateCollectionType(entityType); code.DataContracts.Add(new CodeTypeExtension(collectionType)); CodeTypeReference collectionRef = new CodeTypeReference(collectionType.Name); return(collectionRef); }
public CodeTypeReference CreateCollectionType(CodeTypeReference entityType, ExtendedCodeDomTree code) { Debug.Assert(entityType != null, "Argument entity type could not be null."); // Do not create a ByteCollection as this is not compatiable with base64Binary! if (entityType.BaseType == typeof(byte).FullName) return entityType; CodeTypeReference ctr = new CodeTypeReference(typeof(List<>)); if (entityType.IsNullableType()) { ctr.TypeArguments.Add(entityType.CloseNullableType()); } else { ctr.TypeArguments.Add(entityType.BaseType); } return ctr; }
public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { this.code = code; this.options = options; this.configuration = code.Configuration; // Are we on the service side code gen? if (options.GenerateService) { // Then generate the service side configuration. GenerateServiceConfiguration(); // Do we have to enable metadata endpoint? if (options.EnableWsdlEndpoint) { AddMetadataServiceBehavior(); } } }
public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options) { this.code = code; this.options = options; this.configuration = code.Configuration; // Are we on the service side code gen? if (options.GenerateService) { // Then generate the service side configuration. GenerateServiceConfiguration(); // Do we have to enable metadata endpoint? if (options.EnableWsdlEndpoint) { AddMetadataServiceBehavior(); } } }
public CodeTypeReference CreateCollectionType(CodeTypeReference entityType, ExtendedCodeDomTree code) { Debug.Assert(entityType != null, "Argument entity type could not be null."); // Do not create a ByteCollection as this is not compatiable with base64Binary! if (entityType.BaseType == typeof(byte).FullName) { return(entityType); } CodeTypeReference ctr = new CodeTypeReference(typeof(List <>)); if (entityType.IsNullableType()) { ctr.TypeArguments.Add(entityType.CloseNullableType()); } else { ctr.TypeArguments.Add(entityType.BaseType); } return(ctr); }
public ClientTypeConverter(CodeTypeExtension typeExtension, ExtendedCodeDomTree code) : base(typeExtension, code) { }
public CollectionTypeGenerator(ICollectionTypeProvider collectionTypeProvider, ExtendedCodeDomTree code) { this.collectionTypeProvider = collectionTypeProvider; this.generatedTypes = new Dictionary <string, CodeTypeReference>(); this.code = code; }
public ClientTypeConverter(CodeTypeExtension typeExtension, ExtendedCodeDomTree code) : base(typeExtension, code) { }
public DataContractConverter(CodeTypeExtension typeExtension, ExtendedCodeDomTree code) : base(typeExtension, code) { }
public CollectionTypeGenerator(ICollectionTypeProvider collectionTypeProvider, ExtendedCodeDomTree code) { this.collectionTypeProvider = collectionTypeProvider; this.generatedTypes = new Dictionary<string, CodeTypeReference>(); this.code = code; }
protected PascalCaseConverterBase(CodeTypeExtension codeTypeExtension, ExtendedCodeDomTree code) { this.typeExtension = codeTypeExtension; this.Code = code; this.type = (CodeTypeDeclaration)codeTypeExtension.ExtendedObject; }
protected PascalCaseConverterBase(CodeTypeExtension codeTypeExtension, ExtendedCodeDomTree code) { this.typeExtension = codeTypeExtension; this.Code = code; this.type = (CodeTypeDeclaration)codeTypeExtension.ExtendedObject; }
public ServiceContractConverter(CodeTypeExtension typeExtension, ExtendedCodeDomTree code) : base(typeExtension, code) { }
public static PascalCaseConverterBase GetPascalCaseConverter(CodeTypeExtension typeExtension, ExtendedCodeDomTree code) { switch (typeExtension.Kind) { case CodeTypeKind.DataContract: return(new DataContractConverter(typeExtension, code)); case CodeTypeKind.MessageContract: return(new MessageContractConverter(typeExtension, code)); case CodeTypeKind.ServiceContract: return(new ServiceContractConverter(typeExtension, code)); case CodeTypeKind.ClientType: return(new ClientTypeConverter(typeExtension, code)); default: return(null); } }