Ejemplo n.º 1
0
        protected GenerationContext(GraphQlSchema schema, GeneratedObjectType objectTypes, byte indentationSize)
        {
            var optionsInteger = (int)objectTypes;

            if (optionsInteger != 1 && optionsInteger != 2 && optionsInteger != 3)
            {
                throw new ArgumentException("invalid value", nameof(objectTypes));
            }

            Schema      = schema ?? throw new ArgumentNullException(nameof(schema));
            ObjectTypes = objectTypes;
            Indentation = indentationSize;
        }
Ejemplo n.º 2
0
        public MultipleFileGenerationContext(
            GraphQlSchema schema,
            string outputDirectory,
            string @namespace,
            string projectFileName          = null,
            GeneratedObjectType objectTypes = GeneratedObjectType.DataClasses | GeneratedObjectType.QueryBuilders)
            : base(schema, objectTypes, 4)
        {
            if (!Directory.Exists(outputDirectory))
            {
                throw new ArgumentException($"Directory '{outputDirectory}' does not exist. ", nameof(outputDirectory));
            }

            if (String.IsNullOrWhiteSpace(@namespace))
            {
                throw new ArgumentException("namespace required", nameof(@namespace));
            }

            _outputDirectory = outputDirectory;
            _namespace       = @namespace;
            _projectFileName = projectFileName;
        }
 private static GenerationContext CreateGenerationContext(
     StringBuilder builder,
     GraphQlSchema schema,
     GeneratedObjectType options = GeneratedObjectType.QueryBuilders | GeneratedObjectType.DataClasses) =>
 new SingleFileGenerationContext(schema, new StringWriter(builder), options);
Ejemplo n.º 4
0
 public SingleFileGenerationContext(GraphQlSchema schema, TextWriter writer, GeneratedObjectType objectTypes = GeneratedObjectType.DataClasses | GeneratedObjectType.QueryBuilders, byte indentationSize = 0)
     : base(schema, objectTypes, indentationSize)
 {
     Writer       = writer ?? throw new ArgumentNullException(nameof(writer));
     _indentation = new String(' ', indentationSize);
 }
 private static GenerationContext CreateGenerationContext(
     StringBuilder builder,
     GraphQlSchema schema,
     GeneratedObjectType objectTypes = GeneratedObjectType.All) =>
 new SingleFileGenerationContext(schema, new StringWriter(builder), objectTypes);