Ejemplo n.º 1
0
        public CsharpFieldStringify(CsharpEmitterOptions options)
        {
            _options  = options;
            _template = Template.Parse(
                @"{{~ if description ~}}
/// <summary>
/// {{ description }}
/// </summary>
{{~ end ~}}
{{~ if example ~}}
/// <example>{{ example }}</example>
{{~ end ~}}
{{~ if is_deprecated ~}}
[Obsolete(""{{ deprecation_cause }}"")]
{{~ end ~}}
{{~ if json_property ~}}
[JsonProperty(""{{ json_property }}"")]
{{~ end ~}}
{{~ if query_name ~}}
[Microsoft.AspNetCore.Mvc.FromQuery(Name = ""{{ query_name }}"")]
{{~ end ~}}
{{~ if is_nullable ~}}
[CanBeNull]
{{~ end ~}}
{{~ for v in validations ~}}
{{ v }}
{{~ end ~}}
{{~ for c in custom_attrs ~}}
[{{ c }}]
{{~ end ~}}
public {{prop_type}} {{name}} { get; set; }");
        }
Ejemplo n.º 2
0
        public CsharpManyContractsWrapper(CsharpEmitterOptions options, CsharpTemplateContext contextMaker)
        {
            _options      = options;
            _contextMaker = contextMaker;
            _template     = Template.Parse(
                @"using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace {{ namespace }} {
{{ contracts | ident }}
}");
        }
Ejemplo n.º 3
0
        public CsharpEnumFieldStringify(CsharpEmitterOptions options)
        {
            _options  = options;
            _template = Template.Parse(
                @"{{~ if description ~}}
/// <summary>
/// {{ description }}
/// </summary>
{{~ end ~}}
{{~ if is_deprecated ~}}
[Obsolete(""{{ deprecation_cause }}"")]
{{~ end ~}}
{{~ if json_name ~}}
[EnumMember(Value = ""{{ json_name }}"")]
{{~ end ~}}
{{name}},");
        }
        public CsharpContractGenericStringify(IContractFieldStringify fieldStringify, CsharpEmitterOptions options, CsharpTemplateContext contextMaker)
        {
            _fieldStringify = fieldStringify;
            _options        = options;
            _contextMaker   = contextMaker;
            _template       = Template.Parse(@"{{~ if description ~}}
/// <summary>
/// {{ description }}
/// </summary>
{{~ end ~}}
{{~ if is_deprecated ~}}
[Obsolete(""{{ deprecation_cause }}"")]
{{~ end ~}}
public {{ if can_be_partial }}partial {{ end }}class {{ class_name }}<{{ genericargs }}> {

{{~ for field in fields ~}}
{{ field | ident }}

{{~ end ~}}
}");
        }
Ejemplo n.º 5
0
        public CsharpContractEnumStringify(IEnumFieldStringify fieldStringify, CsharpEmitterOptions options, CsharpTemplateContext contextMaker)
        {
            _fieldStringify = fieldStringify;
            _options        = options;
            _contextMaker   = contextMaker;
            _template       = Template.Parse(@"{{~ if description ~}}
/// <summary>
/// {{ description }}
/// </summary>
{{~ end ~}}
{{~ if is_deprecated ~}}
[Obsolete(""{{ deprecation_cause }}"")]
{{~ end ~}}
{{~ if json_converter ~}}
[JsonConverter(typeof({{ json_converter }}))]
{{~ end ~}}
public enum {{ enum_name }} {

{{~ for field in fields ~}}
{{ field | ident }}

{{~ end ~}}
}");
        }
Ejemplo n.º 6
0
 public CsharpTemplateContext(CsharpEmitterOptions options)
 {
     _options = options;
 }