internal CodeTypeDeclaration GenerateNestedClass(JsonSchema schema, IDictionary <JsonSchema, SchemaImplementationDetails> detailCollection, int orderOfNestedClass) { schema.ThrowIfNull("schema"); string className = knownSubschemas[schema].ClassName; var typeDeclaration = new CodeTypeDeclaration(className); typeDeclaration.Attributes = MemberAttributes.Public; var nestedClassGenerator = new NestedClassGenerator( typeDeclaration, decorators, uniquefier + orderOfNestedClass + "_"); foreach (ISchemaDecorator schemaDecorator in decorators) { if (schemaDecorator is INestedClassSchemaDecorator) { logger.Debug( "Found IInternalClassSchemaDecorator {0} - decorating {1}", schemaDecorator, className); ((INestedClassSchemaDecorator)schemaDecorator).DecorateInternalClass( typeDeclaration, className, schema, detailCollection, nestedClassGenerator); } } nestedClassGenerator.GenerateNestedClasses(detailCollection); return(typeDeclaration); }
/// <summary> /// Creates a fully working class for the specified schema. /// </summary> public CodeTypeDeclaration CreateClass(ISchema schema, IDictionary<JsonSchema, SchemaImplementationDetails> detailCollection, IEnumerable<string> otherSchemaNames) { schema.ThrowIfNull("schema"); detailCollection.ThrowIfNull("detailCollection"); otherSchemaNames.ThrowIfNull("otherSchemaNames"); // Get relevant name collection IEnumerable<string> relevantNames = otherSchemaNames.Without(schema.Name); string className = GeneratorUtils.GetClassName(schema, relevantNames); var typeDeclaration = new CodeTypeDeclaration(className); var nestedClassGenerator = new NestedClassGenerator(typeDeclaration, decorators, ""); foreach (ISchemaDecorator schemaDecorator in decorators) { schemaDecorator.DecorateClass(typeDeclaration, schema, detailCollection, nestedClassGenerator); } nestedClassGenerator.GenerateNestedClasses(detailCollection); return typeDeclaration; }
/// <summary> /// Creates a fully working class for the specified schema. /// </summary> public CodeTypeDeclaration CreateClass(ISchema schema, IDictionary <JsonSchema, SchemaImplementationDetails> detailCollection, IEnumerable <string> otherSchemaNames) { schema.ThrowIfNull("schema"); detailCollection.ThrowIfNull("detailCollection"); otherSchemaNames.ThrowIfNull("otherSchemaNames"); // Get relevant name collection IEnumerable <string> relevantNames = otherSchemaNames.Without(schema.Name); string className = GeneratorUtils.GetClassName(schema, relevantNames); var typeDeclaration = new CodeTypeDeclaration(className); var nestedClassGenerator = new NestedClassGenerator(typeDeclaration, decorators, ""); foreach (ISchemaDecorator schemaDecorator in decorators) { schemaDecorator.DecorateClass(typeDeclaration, schema, detailCollection, nestedClassGenerator); } nestedClassGenerator.GenerateNestedClasses(detailCollection); return(typeDeclaration); }
internal CodeTypeDeclaration GenerateNestedClass(JsonSchema schema, IDictionary<JsonSchema, SchemaImplementationDetails> detailCollection, int orderOfNestedClass) { schema.ThrowIfNull("schema"); string className = knownSubschemas[schema].ClassName; var typeDeclaration = new CodeTypeDeclaration(className); typeDeclaration.Attributes = MemberAttributes.Public; var nestedClassGenerator = new NestedClassGenerator( typeDeclaration, decorators, uniquefier + orderOfNestedClass + "_"); foreach (ISchemaDecorator schemaDecorator in decorators) { if (schemaDecorator is INestedClassSchemaDecorator) { logger.Debug( "Found IInternalClassSchemaDecorator {0} - decorating {1}", schemaDecorator, className); ((INestedClassSchemaDecorator) schemaDecorator).DecorateInternalClass( typeDeclaration, className, schema, detailCollection, nestedClassGenerator); } } nestedClassGenerator.GenerateNestedClasses(detailCollection); return typeDeclaration; }