/// <summary> /// Creates and returns <see cref="AutoBackupSettings"/> object. /// </summary> protected override void ProcessRecord() { AutoBackupSettings autoBackupSettings = new AutoBackupSettings(); autoBackupSettings.Enable = (Enable.IsPresent) ? Enable.ToBool() : false; autoBackupSettings.EnableEncryption = (EnableEncryption.IsPresent) ? EnableEncryption.ToBool() : false; autoBackupSettings.RetentionPeriod = RetentionPeriodInDays; switch (ParameterSetName) { case StorageContextParamSetName: autoBackupSettings.StorageUrl = StorageContext.BlobEndPoint; autoBackupSettings.StorageAccessKey = this.GetStorageKey(); break; case StorageUriParamSetName: autoBackupSettings.StorageUrl = (StorageUri == null) ? null : StorageUri.ToString(); autoBackupSettings.StorageAccessKey = (StorageKey == null) ? null : ConversionUtilities.SecureStringToString(StorageKey); break; } // Check if certificate password was set autoBackupSettings.Password = (CertificatePassword == null) ? null : ConversionUtilities.SecureStringToString(CertificatePassword); autoBackupSettings.BackupSystemDbs = BackupSystemDbs.IsPresent ? BackupSystemDbs.ToBool() : false; autoBackupSettings.BackupScheduleType = BackupScheduleType; // Set other Backup schedule settings only if BackUpSchedule type is Manual. if (!string.IsNullOrEmpty(BackupScheduleType) && string.Equals(BackupScheduleType, ValidateSetValues.Manual, StringComparison.InvariantCultureIgnoreCase)) { ValidateBackupScheduleSettings(); autoBackupSettings.FullBackupFrequency = FullBackupFrequency; autoBackupSettings.FullBackupStartTime = FullBackupStartHour; autoBackupSettings.FullBackupWindowHours = FullBackupWindowInHours; autoBackupSettings.LogBackupFrequency = LogBackupFrequencyInMinutes; } WriteObject(autoBackupSettings); }
/// <summary>Generates the parameter name for the given parameter.</summary> /// <param name="parameter">The parameter.</param> /// <param name="allParameters">All parameters.</param> /// <returns>The parameter name.</returns> public string Generate(OpenApiParameter parameter, IEnumerable <OpenApiParameter> allParameters) { if (string.IsNullOrEmpty(parameter.Name)) { return("unnamed"); } var variableName = ConversionUtilities.ConvertToLowerCamelCase(parameter.Name .Replace("-", "_") .Replace(".", "_") .Replace("+", "_") .Replace("$", string.Empty) .Replace("[", string.Empty) .Replace("]", string.Empty), true); if (allParameters.Count(p => p.Name == parameter.Name) > 1) { return(variableName + parameter.Kind); } return(variableName); }
/// <summary> /// Upserts a managed instance /// </summary> /// <param name="model">The managed instance to upsert</param> /// <returns>The updated managed instance model</returns> public AzureSqlManagedInstanceModel UpsertManagedInstance(AzureSqlManagedInstanceModel model) { var resp = Communicator.CreateOrUpdate(model.ResourceGroupName, model.FullyQualifiedDomainName, new Management.Sql.Models.ManagedInstance() { Location = model.Location, Tags = model.Tags, AdministratorLogin = model.AdministratorLogin, AdministratorLoginPassword = model.AdministratorPassword != null ? ConversionUtilities.SecureStringToString(model.AdministratorPassword) : null, Sku = model.Sku != null ? new Management.Sql.Models.Sku(model.Sku.Name, model.Sku.Tier) : null, LicenseType = model.LicenseType, StorageSizeInGB = model.StorageSizeInGB, SubnetId = model.SubnetId, VCores = model.VCores, Identity = model.Identity, Collation = model.Collation, PublicDataEndpointEnabled = model.PublicDataEndpointEnabled, ProxyOverride = model.ProxyOverride, TimezoneId = model.TimezoneId, }); return(CreateManagedInstanceModelFromResponse(resp)); }
public PropertyModel(JsonProperty property, TypeScriptTypeResolver resolver, TypeScriptGeneratorSettings settings, TypeScriptGenerator generator) : base(property) { var propertyName = ConversionUtilities.ConvertToLowerCamelCase(property.Name).Replace("-", "_"); Name = property.Name; InterfaceName = property.Name.Contains("-") ? '\"' + property.Name + '\"' : property.Name; PropertyName = propertyName; Type = resolver.Resolve(property.ActualPropertySchema, property.IsNullable, property.Name); DataConversionCode = settings.TypeStyle == TypeScriptTypeStyle.Interface ? string.Empty : generator.GenerateDataConversion( settings.TypeStyle == TypeScriptTypeStyle.Class ? "this." + propertyName : propertyName, "data[\"" + property.Name + "\"]", property.ActualPropertySchema, property.IsNullable, property.Name); Description = property.Description; HasDescription = !string.IsNullOrEmpty(property.Description); IsArray = property.ActualPropertySchema.Type.HasFlag(JsonObjectType.Array); ArrayItemType = resolver.TryResolve(property.ActualPropertySchema.Item, property.Name); IsReadOnly = property.IsReadOnly && settings.GenerateReadOnlyKeywords; IsOptional = !property.IsRequired; }
/// <summary>Resolves the type of the parameter.</summary> /// <param name="parameter">The parameter.</param> /// <returns>The parameter type name.</returns> protected virtual string ResolveParameterType(SwaggerParameter parameter) { var schema = parameter.ActualSchema; if (parameter.IsXmlBodyParameter) { return("string"); } if (parameter.CollectionFormat == SwaggerParameterCollectionFormat.Multi && !schema.Type.HasFlag(JsonObjectType.Array)) { schema = new JsonSchema4 { Type = JsonObjectType.Array, Item = schema } } ; var typeNameHint = ConversionUtilities.ConvertToUpperCamelCase(parameter.Name, true); return(_resolver.Resolve(schema, parameter.IsRequired == false || parameter.IsNullable(_settings.CodeGeneratorSettings.NullHandling), typeNameHint)); } }
public static (bool isSingleClient, string typeName) GenerateCSharp(SwaggerDocument document, ApiClientDefinition definition) { var nameGenerator = new CustomNameGenerator(); var settings = new SwaggerToCSharpClientGeneratorSettings() { GenerateSyncMethods = true, OperationNameGenerator = nameGenerator, GenerateOptionalParameters = true }; settings.CSharpGeneratorSettings.ClassStyle = CSharpClassStyle.Poco; settings.CSharpGeneratorSettings.Namespace = definition.Namespace; settings.CSharpGeneratorSettings.ArrayType = "System.Collections.Generic.List"; settings.CSharpGeneratorSettings.PropertyNameGenerator = new MyPropertyNameGenerator(c => ConversionUtilities.ConvertToUpperCamelCase(c, true)); settings.CSharpGeneratorSettings.TypeNameGenerator = new DotvmmCSharpTypeNameGenerator(settings.CSharpGeneratorSettings); settings.CSharpGeneratorSettings.TemplateFactory = new DotvvmClientTemplateFactory(settings.CodeGeneratorSettings, new [] { typeof(CSharpGeneratorSettings).Assembly, typeof(SwaggerToCSharpGeneratorSettings).Assembly }); var resolver = SwaggerToCSharpTypeResolver.CreateWithDefinitions(settings.CSharpGeneratorSettings, document); var generator = new DotvvmSwaggerToCSharpClientGenerator(document, settings, resolver); var csharp = generator.GenerateFile(); var newClient = InjectWrapperClass(csharp, Path.GetFileNameWithoutExtension(definition.CSharpClient), document, settings.OperationNameGenerator, out var isSingleClient, out var wrapperTypeName); definition.IsSingleClient = isSingleClient; if (definition.GenerateWrapperClass) { csharp = newClient; } File.WriteAllText(definition.CSharpClient, csharp); return(isSingleClient, wrapperTypeName); }
/// <summary>Initializes a new instance of the <see cref="ExtensionCode" /> class.</summary> /// <param name="code">The code.</param> /// <param name="extendedClasses">The extended classes.</param> /// <param name="baseClasses">The base classes.</param> public TypeScriptExtensionCode(string code, string[] extendedClasses, string[] baseClasses = null) { code = code .Replace("\r", string.Empty) .Replace("generated.", string.Empty) + "\n"; code = Regex.Replace(code, "import generated (=|from) (.*?)\\n", string.Empty, RegexOptions.Multiline); code = Regex.Replace(code, "import \\* as generated from (.*?)\\n", string.Empty, RegexOptions.Multiline); code = Regex.Replace(code, "(import ((.|\\n)*?) (=|from) (.*?)\\n)|(/// <reference path(.*?)\\n)", match => { ImportCode += ConversionUtilities.TrimWhiteSpaces(match.Groups[0].Value) + "\n"; return(string.Empty); }, RegexOptions.Multiline); code = Regex.Replace(code, "(@.*\r?\n)?(export )?class (.*?) ([\\s\\S]*?)\\n}", match => { var hasExport = match.Groups[2].Success; var className = match.Groups[3].Value; var classCode = hasExport ? match.Groups[0].Value : match.Groups[0].Value.Replace("class ", "export class "); if (extendedClasses?.Contains(className) == true) { ExtensionClasses[className] = classCode; return(string.Empty); } if (baseClasses?.Contains(className) == true) { TopCode += classCode + "\n\n"; return(string.Empty); } return(match.Groups[0].Value); }, RegexOptions.Multiline); ImportCode = ConversionUtilities.TrimWhiteSpaces(ImportCode); TopCode = ConversionUtilities.TrimWhiteSpaces(TopCode); BottomCode = ConversionUtilities.TrimWhiteSpaces(code.Trim()); }
internal override string RenderClientCode(string controllerName, IEnumerable <OperationModel> operations) { var hasClientBaseClass = !string.IsNullOrEmpty(Settings.ClientBaseClass); var template = new ClientTemplate(); template.Initialize(new { Class = Settings.ClassName.Replace("{controller}", ConversionUtilities.ConvertToUpperCamelCase(controllerName)), BaseClass = Settings.ClientBaseClass, HasBaseClass = hasClientBaseClass, HasBaseType = Settings.GenerateClientInterfaces || hasClientBaseClass, UseHttpClientCreationMethod = Settings.UseHttpClientCreationMethod, GenerateClientInterfaces = Settings.GenerateClientInterfaces, BaseUrl = _service.BaseUrl, HasOperations = operations.Any(), Operations = operations }); return(template.Render()); }
/// <summary>Gets the type name hint for the property.</summary> protected string GetTypeNameHint() { var propertyName = PropertyName; if (_property.IsEnumeration == false) { return(propertyName); } var className = _classTemplateModel.ClassName; if (className.Contains("Anonymous")) { return(propertyName); } if (propertyName.StartsWith(className, StringComparison.OrdinalIgnoreCase)) { return(propertyName); } return(className + ConversionUtilities.ConvertToUpperCamelCase(PropertyName, false)); }
public static void GenerateTS(SwaggerDocument document, ApiClientDefinition definition) { var settings = new SwaggerToTypeScriptClientGeneratorSettings() { Template = TypeScriptTemplate.Fetch, OperationNameGenerator = new CustomNameGenerator() }; settings.TypeScriptGeneratorSettings.PropertyNameGenerator = new MyPropertyNameGenerator(c => ConversionUtilities.ConvertToLowerCamelCase(c, true)); settings.TypeScriptGeneratorSettings.NullValue = TypeScriptNullValue.Null; var generator = new SwaggerToTypeScriptClientGenerator(document, settings); var ts = generator.GenerateFile(); ts = "namespace " + definition.Namespace + " {\n " + ConversionUtilities.Tab(ts, 1).TrimEnd('\n') + "\n}\n"; File.WriteAllText(definition.TypescriptClient, ts); if (definition.CompileTypescript) { Process.Start("tsc", definition.TypescriptClient).WaitForExit(); } }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app"></param> /// <param name="args"></param> public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args) { try { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName)); ConversionUtilities unityConverter = new ConversionUtilities(app, TEMP_DIRECTORY, CONVERTER_DIRECTORY); List <FileDefinition> files = unityConverter.Convert(args.Document, UnityFileConversions.ImxFileType.Image, UnityFileConversions.ImportType.Document, app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE), true); unityConverter.CleanupFiles(); args.ScriptResult = true; } catch (InvalidProgramException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (UnityAPIException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (Exception ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } finally { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("End Script - [{0}]", ScriptName)); } }
public static void UpdateProject(string oldProjectName, Project updatedProject) { try { string projectsPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); using (SQLiteConnection Conn = new SQLiteConnection()) { Conn.ConnectionString = "Data Source=" + projectsPath + @"\\Projects\\" + oldProjectName + ".db;New=False;Compress=True;Synchronous=Off"; Conn.Open(); SQLiteCommand DeleteCmd = new SQLiteCommand(); DeleteCmd = Conn.CreateCommand(); DeleteCmd.CommandText = "DELETE FROM project WHERE id_project=1"; DeleteCmd.ExecuteNonQuery(); DeleteCmd.Dispose(); SQLiteParameter idproject = new SQLiteParameter("@idproject", DbType.Int64) { Value = 1 }; SQLiteParameter newproject = new SQLiteParameter("@project", DbType.String) { Value = ConversionUtilities.SerializeBase64(updatedProject) }; SQLiteCommand InsertCmd = new SQLiteCommand(); InsertCmd = Conn.CreateCommand(); InsertCmd.Parameters.Add(idproject); InsertCmd.Parameters.Add(newproject); InsertCmd.CommandText = "INSERT INTO project (id_project, project_base64) VALUES(@idproject, @project)"; InsertCmd.ExecuteNonQuery(); InsertCmd.Dispose(); } } catch (Exception ex) { throw ex; } }
void BtCreateSamplesClick(object sender, EventArgs e) { if (_folderSelected == DialogResult.OK) { foreach (string jpg in Directory.GetFiles(Path.GetFullPath(txtPicturesFolder.Text), "*.jpg")) { Sample nextSample = new Sample(_updatedStation.Lat, _updatedStation.Lon, jpg); //OCR template for presure in inHg OCR_Template ocrPres = new OCR_Template("ocrPres", "Moultrie Game Camera", new Rectangle(71, 2018, 225, 96), new Size(2848, 2136)); //OCR template for temp in ºC OCR_Template ocrTemp = new OCR_Template("ocrTemp", "Moultrie Game Camera", new Rectangle(847, 2024, 196, 111), new Size(2848, 2136)); nextSample.OCR_Observations_list.Add(new DoubleObservation("Pressure (inHg)", "", ocrPres)); nextSample.OCR_Observations_list.Add(new IntegerObservation("Temperature (ºC)", "", ocrTemp)); nextSample.Species_Observations_list.Add(new SpeciesObservation("Species", "Pending", 0)); nextSample.RunOCR(nextSample.OCR_Observations_list); Image nextImage = Image.FromFile(jpg); foreach (Station st in _updatedProject.StationsList) { if (st.Guid == _updatedStation.Guid) { st.SamplesList.Add(nextSample); } } ProjectDAO.InsertImage(_updatedProject.Name, nextSample.Guid, ConversionUtilities.ImageToBase64(nextImage, System.Drawing.Imaging.ImageFormat.Jpeg)); } ProjectDAO.UpdateProject(_updatedProject.Name, _updatedProject); } }
/// <summary>Generates the enumeration name/key of the given enumeration entry.</summary> /// <param name="index">The index of the enumeration value (check <see cref="JsonSchema.Enumeration" /> and <see cref="JsonSchema.EnumerationNames" />).</param> /// <param name="name">The name/key.</param> /// <param name="value">The value.</param> /// <param name="schema">The schema.</param> /// <returns>The enumeration name.</returns> public string Generate(int index, string name, object value, JsonSchema schema) { if (string.IsNullOrEmpty(name)) { return("Empty"); } if (name.StartsWith("_-")) { name = "__" + name.Substring(2); } return(ConversionUtilities.ConvertToUpperCamelCase(name .Replace(":", "-").Replace(@"""", @""), true) .Replace(".", "_") .Replace(",", "_") .Replace("#", "_") .Replace("&", "_") .Replace("-", "_") .Replace("'", "_") .Replace("(", "_") .Replace(")", "_") .Replace("\\", "_")); }
public string Generate(OpenApiParameter parameter, IEnumerable <OpenApiParameter> allParameters) { const string customHeaderPrefix = "x_"; if (string.IsNullOrEmpty(parameter.Name)) { return("unnamed"); } var lowerCamelCase = ConversionUtilities.ConvertToLowerCamelCase(parameter.Name.Replace("-", "_") .Replace(".", "_").Replace("$", string.Empty) .Replace("[", string.Empty) .Replace("]", string.Empty), true); if (lowerCamelCase.Length <= customHeaderPrefix.Length || !lowerCamelCase.StartsWith(customHeaderPrefix)) { return(lowerCamelCase); } lowerCamelCase = lowerCamelCase.Remove(0, customHeaderPrefix.Length); lowerCamelCase = char.ToLowerInvariant(lowerCamelCase[0]) + lowerCamelCase.Substring(1); return(lowerCamelCase); }
/// <summary> /// Gets the numerical character reference value. /// </summary> /// <param name="str">The STR.</param> /// <returns></returns> protected string GetNumericalCharacterReferenceValue(string str) { if (str != null && str.Length > 1) { if (str[0] == '#') { int val; if (str[1] == 'x' || str[1] == 'X') { val = ConversionUtilities.ParseHex(str.Substring(2)); } else { val = ConversionUtilities.ParseInt(str.Substring(1)); } if (val > 0) { return(((char)val).ToString()); } } } return(null); }
private string GenerateInternal(JsonSchema4 schema) { if (!string.IsNullOrEmpty(schema.TypeNameRaw)) { return(ConversionUtilities.ConvertToUpperCamelCase(schema.TypeNameRaw, true)); } if (schema.ExtensionData != null && schema.ExtensionData.Any() && schema.ExtensionData.ContainsKey("typeName")) { return(ConversionUtilities.ConvertToUpperCamelCase(schema.ExtensionData["typeName"].ToString(), true)); } if (!string.IsNullOrEmpty(schema.Title)) { return(ConversionUtilities.ConvertToUpperCamelCase(schema.Title, true)); } if (schema.ParentSchema == null) { return(defaultRootName); } return(null); }
internal override string RenderClientCode(string controllerName, IEnumerable <OperationModel> operations) { GenerateDataConversionCodes(operations); var template = Settings.CreateTemplate(); template.Initialize(new { Class = Settings.ClassName.Replace("{controller}", ConversionUtilities.ConvertToUpperCamelCase(controllerName)), HasOperations = operations.Any(), Operations = operations, UsesKnockout = Settings.TypeScriptGeneratorSettings.TypeStyle == TypeScriptTypeStyle.KnockoutClass, GenerateClientInterfaces = Settings.GenerateClientInterfaces, BaseUrl = _service.BaseUrl, UseDtoClasses = Settings.TypeScriptGeneratorSettings.TypeStyle != TypeScriptTypeStyle.Interface, PromiseType = Settings.PromiseType == PromiseType.Promise ? "Promise" : "Q.Promise", PromiseConstructor = Settings.PromiseType == PromiseType.Promise ? "new Promise" : "Q.Promise" }); return(template.Render()); }
internal override bool TryBoolEvaluate(ConditionEvaluator.IConditionEvaluationState state, out bool result) { return(ConversionUtilities.TryConvertStringToBool(GetExpandedValue(state), out result)); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("\r\n[System.CodeDom.Compiler.GeneratedCode(\"NSwag\", \""); #line 4 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\npublic interface I"); #line 5 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("Controller\r\n{\r\n"); #line 7 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" foreach (var operation in Model.Operations) { #line default #line hidden #line 8 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (operation.HasSummary) { #line default #line hidden this.Write(" /// <summary>"); #line 8 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.ConvertCSharpDocBreaks(operation.Summary, 1))); #line default #line hidden this.Write("</summary>\r\n"); #line 9 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } foreach (var parameter in operation.Parameters) { #line default #line hidden #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (parameter.HasDescription) { #line default #line hidden this.Write(" /// <param name=\""); #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden this.Write("\">"); #line 10 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.ConvertCSharpDocBreaks(parameter.Description, 1))); #line default #line hidden this.Write("</param>\r\n"); #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } } if (operation.HasResultDescription) { #line default #line hidden this.Write(" /// <returns>"); #line 11 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.ConvertCSharpDocBreaks(operation.ResultDescription, 1))); #line default #line hidden this.Write("</returns>\r\n"); #line 12 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } if (operation.IsDeprecated) { #line default #line hidden this.Write(" [System.Obsolete]\r\n"); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } #line default #line hidden this.Write(" "); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); #line default #line hidden this.Write(" "); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); #line default #line hidden this.Write("Async("); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" foreach (var parameter in operation.Parameters) { #line default #line hidden #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type)); #line default #line hidden this.Write(" "); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (Model.GenerateOptionalParameters && parameter.IsOptional) { #line default #line hidden this.Write(" = null"); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } #line default #line hidden #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (!parameter.IsLast) { #line default #line hidden this.Write(", "); #line 13 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } } #line default #line hidden this.Write(");\r\n\r\n"); #line 15 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } #line default #line hidden this.Write("}\r\n\r\n[System.CodeDom.Compiler.GeneratedCode(\"NSwag\", \""); #line 18 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n"); #line 19 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (Model.HasBasePath) { #line default #line hidden this.Write("[System.Web.Http.RoutePrefix(\""); #line 20 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BasePath)); #line default #line hidden this.Write("\")]\r\n"); #line 21 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } #line default #line hidden this.Write("public partial class "); #line 22 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("Controller : "); #line 22 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (Model.HasBaseClass) { #line default #line hidden #line 22 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseClass)); #line default #line hidden #line 22 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } else { #line default #line hidden this.Write("System.Web.Http.ApiController"); #line 22 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } #line default #line hidden this.Write(" \r\n{\r\n private I"); #line 24 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("Controller _implementation; \r\n\r\n public "); #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("Controller(I"); #line 26 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("Controller implementation)\r\n {\r\n _implementation = implementation; \r\n " + " }\r\n"); #line 30 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" foreach (var operation in Model.Operations) { #line default #line hidden #line 31 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (operation.HasSummary) { #line default #line hidden this.Write(" /// <summary>"); #line 31 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.ConvertCSharpDocBreaks(operation.Summary, 1))); #line default #line hidden this.Write("</summary>\r\n"); #line 32 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } foreach (var parameter in operation.Parameters) { #line default #line hidden #line 33 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (parameter.HasDescription) { #line default #line hidden this.Write(" /// <param name=\""); #line 33 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden this.Write("\">"); #line 33 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.ConvertCSharpDocBreaks(parameter.Description, 1))); #line default #line hidden this.Write("</param>\r\n"); #line 34 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } } if (operation.HasResultDescription) { #line default #line hidden this.Write(" /// <returns>"); #line 34 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.ConvertCSharpDocBreaks(operation.ResultDescription, 1))); #line default #line hidden this.Write("</returns>\r\n"); #line 35 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } if (operation.IsDeprecated) { #line default #line hidden this.Write(" [System.Obsolete]\r\n"); #line 36 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } #line default #line hidden this.Write(" [System.Web.Http.Http"); #line 36 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.HttpMethodUpper)); #line default #line hidden this.Write(", System.Web.Http.Route(\""); #line 36 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Path)); #line default #line hidden this.Write("\")]\r\n public "); #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.ResultType)); #line default #line hidden this.Write(" "); #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); #line default #line hidden this.Write("("); #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" foreach (var parameter in operation.Parameters) { #line default #line hidden #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.Type)); #line default #line hidden this.Write(" "); #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (Model.GenerateOptionalParameters && parameter.IsOptional) { #line default #line hidden this.Write(" = null"); #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } #line default #line hidden #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (!parameter.IsLast) { #line default #line hidden this.Write(", "); #line 37 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } } #line default #line hidden this.Write(")\r\n {\r\n return _implementation."); #line 39 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.OperationNameUpper)); #line default #line hidden this.Write("Async("); #line 39 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" foreach (var parameter in operation.Parameters) { #line default #line hidden #line 39 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(parameter.VariableName)); #line default #line hidden #line 39 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" if (!parameter.IsLast) { #line default #line hidden this.Write(", "); #line 39 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } } #line default #line hidden this.Write(");\r\n }\r\n\r\n"); #line 42 "C:\Data\NSwag\src\NSwag.CodeGeneration.CSharp\Templates\ControllerTemplate.tt" } #line default #line hidden this.Write("}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("//----------------------\r\n// <auto-generated>\r\n// Generated using the NSwag t" + "oolchain v"); #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write(" (NJsonSchema v"); #line 5 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(JsonSchema4.ToolchainVersion)); #line default #line hidden this.Write(@") (http://NSwag.org) // </auto-generated> //---------------------- using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.IO; using System.Linq; "); #line 18 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.GenerateImplementation && Model.GenerateClientClasses) { #line default #line hidden this.Write("using System.Net;\r\nusing System.Net.Http;\r\n"); #line 21 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write(@"using System.Reflection; using System.Runtime.Serialization; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using System.Text; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; "); #line 32 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" foreach (var usage in Model.NamespaceUsages) { #line default #line hidden this.Write("using "); #line 32 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(usage)); #line default #line hidden this.Write(";\r\n"); #line 33 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("\r\nnamespace "); #line 35 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Namespace)); #line default #line hidden this.Write("\r\n{\r\n #pragma warning disable // Disable all warnings\r\n\r\n "); #line 39 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Clients, 1))); #line default #line hidden this.Write("\r\n\r\n"); #line 41 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.GenerateContracts) { #line default #line hidden this.Write(" "); #line 42 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(Model.Classes, 1))); #line default #line hidden this.Write("\r\n\r\n"); #line 44 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.RequiresFileParameterType) { #line default #line hidden this.Write(" [GeneratedCode(\"NSwag\", \""); #line 45 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write(@""")] public class FileParameter { public FileParameter(Stream data) : this (data, null) { } public FileParameter(Stream data, string fileName) { Data = data; FileName = fileName; } public Stream Data { get; private set; } public string FileName { get; private set; } } " ); #line 63 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 65 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" foreach (var exceptionClassName in Model.ExceptionClassNames) { #line default #line hidden this.Write(" [GeneratedCode(\"NSwag\", \""); #line 66 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 67 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(" : Exception\r\n {\r\n public string StatusCode { get; private set; }\r\n\r\n " + " public byte[] ResponseData { get; private set; }\r\n\r\n public "); #line 73 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write(@"(string message, string statusCode, byte[] responseData, Exception innerException) : base(message, innerException) { StatusCode = statusCode; ResponseData = responseData; } public override string ToString() { return string.Format(""HTTP Response: n{0}n{1}"", Encoding.UTF8.GetString(ResponseData, 0, ResponseData.Length), base.ToString()); } } [GeneratedCode(""NSwag"", """); #line 86 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(SwaggerDocument.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\n public class "); #line 87 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("<TResponse> : "); #line 87 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("\r\n {\r\n public TResponse Response { get; private set; }\r\n\r\n publi" + "c "); #line 91 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exceptionClassName)); #line default #line hidden this.Write("(string message, string statusCode, byte[] responseData, TResponse response, Exce" + "ption innerException) \r\n : base(message, statusCode, responseData, in" + "nerException)\r\n {\r\n Response = response;\r\n }\r\n }\r\n\r\n" + ""); #line 98 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 99 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 100 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.GenerateImplementation) { #line default #line hidden #line 101 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" if (Model.RequiresJsonExceptionConverter) { #line default #line hidden this.Write(" "); #line 102 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.JsonExceptionConverterCode)); #line default #line hidden this.Write("\r\n"); #line 103 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden #line 104 "C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\CodeGenerators\CSharp\Templates\FileTemplate.tt" } #line default #line hidden this.Write("}"); return(this.GenerationEnvironment.ToString()); }
public string Generate(JsonSchema4 schema) { return("MyCustomType" + ConversionUtilities.ConvertToUpperCamelCase(schema.TypeNameRaw)); }
public string Generate(JsonProperty property) { return("MyCustom" + ConversionUtilities.ConvertToUpperCamelCase(property.Name)); }
/// <summary>Generates the name of the controller based on the provided settings.</summary> /// <param name="controllerName">Name of the controller.</param> /// <returns>The controller name.</returns> public string GenerateControllerName(string controllerName) { return(ClassName.Replace("{controller}", ConversionUtilities.ConvertToUpperCamelCase(controllerName, false))); }
/// <summary>Renders the request body generation code.</summary> /// <param name="operation">The operation.</param> /// <param name="tabCount">The tab count.</param> /// <returns>Rendered request body</returns> public static string Render(OperationModel operation, int tabCount = 0) { var tpl = new RequestBodyTemplate(operation); return(ConversionUtilities.Tab(tpl.Render(), tabCount)); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {\r\n"); #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden #line 6 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write(" = "); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsArray) { #line default #line hidden this.Write("ko.observableArray<"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.ArrayItemType)); #line default #line hidden this.Write(">("); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write("ko.observable<"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.TypePostfix)); #line default #line hidden this.Write(">("); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(";\r\n"); #line 10 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 12 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write("\r\n protected _discriminator: string;\r\n"); #line 15 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 17 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden this.Write(" constructor() {\r\n"); #line 19 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super();\r\n"); #line 21 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" this._discriminator = \""); #line 22 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DiscriminatorName)); #line default #line hidden this.Write("\";\r\n }\r\n"); #line 24 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\r\n init(data?: any"); #line 26 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write(", _mappings?: any"); #line 26 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(") {\r\n"); #line 27 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super.init(data);\r\n"); #line 29 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" if (data !== undefined) {\r\n"); #line 31 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" var "); #line 32 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_: any; \r\n "); #line 33 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToClassCode, 3))); #line default #line hidden this.Write("\r\n this."); #line 34 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("("); #line 34 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_);\r\n\r\n"); #line 36 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n\r\n static fromJS(data: any"); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden this.Write(", _mappings?: any"); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("): "); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(" {\r\n"); #line 41 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HandleReferences) { #line default #line hidden #line 42 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden #line 43 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 44 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 44 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\")\r\n return createInstance<"); #line 45 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write(">(data, _mappings, "); #line 45 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write(");\r\n"); #line 46 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" return createInstance<"); #line 47 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(">(data, _mappings, "); #line 47 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(");\r\n"); #line 48 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write(" return createInstance<"); #line 49 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(">(data, _mappings, "); #line 49 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(");\r\n"); #line 50 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 51 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden #line 52 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden #line 53 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 54 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 54 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\") {\r\n let result = new "); #line 55 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("();\r\n result.init(data);\r\n return result;\r\n }\r\n"); #line 59 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 60 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" let result = new "); #line 61 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("();\r\n result.init(data);\r\n return result;\r\n"); #line 64 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n\r\n toJSON(data?: any) {\r\n data = typeof data === \'object\' ? data" + " : {};\r\n"); #line 69 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" data[\""); #line 70 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] = this._discriminator; \r\n"); #line 71 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 72 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" let "); #line 73 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_: any = this."); #line 73 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("(); \r\n "); #line 74 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToJavaScriptCode, 2))); #line default #line hidden this.Write("\r\n\r\n"); #line 76 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } if (Model.HasInheritance) { #line default #line hidden this.Write(" super.toJSON(data);\r\n"); #line 78 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" return data; \r\n }\r\n"); #line 81 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.GenerateCloneMethod) { #line default #line hidden this.Write("\r\n clone() {\r\n const json = this.toJSON();\r\n let result = new "); #line 85 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write("();\r\n result.init(json);\r\n return result;\r\n }\r\n"); #line 89 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("\n"); this.Write("\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write("\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write(" = "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.IsArray) { #line default #line hidden this.Write("ko.observableArray<"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.ArrayItemType)); #line default #line hidden this.Write(">("); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write("ko.observable<"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden this.Write(">("); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(")"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(";\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\n\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write("\n protected _discriminator: string;\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\n\n constructor(data?: any) {\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write("\n super(data);\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden this.Write("\n this._discriminator = \""); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DiscriminatorName)); #line default #line hidden this.Write("\";\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\n if (data !== undefined) {\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write("\n var "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_: "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden this.Write(" = null; \n "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToClassCode, 3))); #line default #line hidden this.Write("\n this."); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("("); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_);\n\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write(" }\n }\n\n static fromJS(data: any): "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write(" {\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasBaseDiscriminator) { foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write("\n if (data[\""); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\")\n return new "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("(data);\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\n return new "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } else { #line default #line hidden this.Write("\n return new "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\n }\n\n toJS(data?: any) {\n data = data === undefined ? {} : data;\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write("\n data[\""); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] = this._discriminator; \n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write("\n var "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("_ = this."); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden this.Write("(); \n "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToJavaScriptCode, 2))); #line default #line hidden this.Write("\n\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } if (Model.HasInheritance) { #line default #line hidden this.Write("\n super.toJS(data);\n"); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" } #line default #line hidden this.Write("\n return data; \n }\n\n toJSON() {\n return JSON.stringify(this.t" + "oJS());\n }\n\n clone() {\n var json = this.toJSON();\n return ne" + "w "); #line 1 "C:\Data\NJsonSchema\src\NJsonSchema.CodeGeneration.TypeScript\Templates\KnockoutClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(JSON.parse(json));\n }\n}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 2 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/** "); #line 2 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Description)); #line default #line hidden this.Write(" */\r\n"); #line 3 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("export class "); #line 3 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden #line 3 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write(" {"); #line 3 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" \r\n"); #line 4 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /** "); #line 4 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Description)); #line default #line hidden this.Write(" */\r\n"); #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" "); #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.IsReadOnly) { #line default #line hidden this.Write("readonly "); #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.HasFullName) { #line default #line hidden #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyFullName)); #line default #line hidden #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } else { #line default #line hidden #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.IsOptional) { #line default #line hidden this.Write("?"); #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(": "); #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden this.Write(" = "); #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(";"); #line 5 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 7 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" protected _discriminator: string;\r\n"); #line 9 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n constructor(data?: any) {\r\n"); #line 12 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasInheritance) { #line default #line hidden this.Write(" super(data);\r\n"); #line 14 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 15 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { #line default #line hidden this.Write(" this._discriminator = \""); #line 16 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.DiscriminatorName)); #line default #line hidden this.Write("\";\r\n"); #line 17 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" if (data !== undefined) {\r\n"); #line 19 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 20 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToClassCode, 3))); #line default #line hidden this.Write("\r\n"); #line 21 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n }\r\n\r\n static fromJS(data: any): "); #line 25 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write(" {\r\n"); #line 26 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasBaseDiscriminator) { foreach (var derivedClass in Model.DerivedClassNames) { #line default #line hidden this.Write(" if (data[\""); #line 28 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] === \""); #line 28 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("\")\r\n return new "); #line 29 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass)); #line default #line hidden this.Write("(data);\r\n"); #line 30 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return new "); #line 31 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\r\n"); #line 32 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } else { #line default #line hidden this.Write(" return new "); #line 33 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(data);\r\n"); #line 34 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n\r\n toJS(data?: any) {\r\n data = data === undefined ? {} : data;\r\n" + ""); #line 39 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write(" data[\""); #line 40 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.BaseDiscriminator)); #line default #line hidden this.Write("\"] = this._discriminator; \r\n"); #line 41 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden #line 42 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" "); #line 43 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.Tab(property.ConvertToJavaScriptCode, 2))); #line default #line hidden this.Write("\r\n"); #line 44 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } if (Model.HasInheritance) { #line default #line hidden this.Write(" super.toJS(data);\r\n"); #line 46 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" return data; \r\n }\r\n\r\n toJSON() {\r\n return JSON.stringify(thi" + "s.toJS());\r\n }\r\n\r\n clone() {\r\n var json = this.toJSON();\r\n r" + "eturn new "); #line 56 "C:\Users\ardoerfl\Source\Repos\NJsonSchema\src\NJsonSchema.CodeGeneration\TypeScript\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.ActualClass)); #line default #line hidden this.Write("(JSON.parse(json));\r\n }\r\n}"); return(this.GenerationEnvironment.ToString()); }
public string Render() { return(ConversionUtilities.TrimWhiteSpaces(TransformText())); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { #line 2 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (Model.HasDescription) { #line default #line hidden this.Write("/// <summary>"); #line 3 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.ConvertCSharpDocBreaks(Model.Description, 0))); #line default #line hidden this.Write("</summary>\r\n"); #line 4 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 5 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (Model.HasDiscriminator) { #line default #line hidden this.Write("[Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), \""); #line 6 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Discriminator)); #line default #line hidden this.Write("\")]\r\n"); #line 7 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" foreach (var derivedClass in Model.DerivedClasses) { #line default #line hidden this.Write("[JsonInheritanceAttribute(\""); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass.Key)); #line default #line hidden this.Write("\", typeof("); #line 8 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(derivedClass.Value)); #line default #line hidden this.Write("))]\r\n"); #line 9 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 10 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("[System.CodeDom.Compiler.GeneratedCode(\"NJsonSchema\", \""); #line 11 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(JsonSchema4.ToolchainVersion)); #line default #line hidden this.Write("\")]\r\npublic partial class "); #line 12 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(" "); #line 12 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Inheritance)); #line default #line hidden this.Write("\r\n{\r\n"); #line 14 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (Model.Inpc) { #line default #line hidden #line 15 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden this.Write(" private "); #line 16 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden this.Write(" "); #line 16 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.FieldName)); #line default #line hidden #line 16 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden this.Write(" = "); #line 16 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden #line 16 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(";\r\n"); #line 17 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 19 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 20 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" foreach (var property in Model.Properties) { #line default #line hidden #line 21 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.HasDescription) { #line default #line hidden this.Write(" /// <summary>"); #line 22 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ConversionUtilities.ConvertCSharpDocBreaks(property.Description, 1))); #line default #line hidden this.Write("</summary>\r\n"); #line 23 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" [Newtonsoft.Json.JsonProperty(\""); #line 24 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Name)); #line default #line hidden this.Write("\", Required = "); #line 24 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.JsonPropertyRequired)); #line default #line hidden #line 24 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.IsStringEnumArray) { #line default #line hidden this.Write(", ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter)"); #line 24 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(")]\r\n"); #line 25 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.RenderRequiredAttribute) { #line default #line hidden this.Write(" [System.ComponentModel.DataAnnotations.Required]\r\n"); #line 27 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 28 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.RenderRangeAttribute) { #line default #line hidden this.Write(" [System.ComponentModel.DataAnnotations.Range("); #line 29 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.RangeMinimumValue)); #line default #line hidden this.Write(", "); #line 29 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.RangeMaximumValue)); #line default #line hidden this.Write(")]\r\n"); #line 30 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 31 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.RenderStringLengthAttribute) { #line default #line hidden this.Write(" [System.ComponentModel.DataAnnotations.StringLength("); #line 32 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.StringLengthMaximumValue)); #line default #line hidden #line 32 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.StringLengthMinimumValue > 0) { #line default #line hidden this.Write(", MinimumLength = "); #line 32 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.StringLengthMinimumValue)); #line default #line hidden #line 32 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(")]\r\n"); #line 33 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 34 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.RenderRegularExpressionAttribute) { #line default #line hidden this.Write(" [System.ComponentModel.DataAnnotations.RegularExpression(@\""); #line 35 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.RegularExpressionValue)); #line default #line hidden this.Write("\")]\r\n"); #line 36 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 37 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.IsStringEnum) { #line default #line hidden this.Write(" [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumCo" + "nverter))]\r\n"); #line 39 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" public "); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.Type)); #line default #line hidden this.Write(" "); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.PropertyName)); #line default #line hidden #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (!Model.Inpc) { #line default #line hidden this.Write(" { get; "); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.HasSetter) { #line default #line hidden this.Write("set; "); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("}"); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.HasDefaultValue) { #line default #line hidden this.Write(" = "); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.DefaultValue)); #line default #line hidden this.Write(";"); #line 40 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 42 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } else { #line default #line hidden this.Write("\r\n {\r\n get { return "); #line 45 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.FieldName)); #line default #line hidden this.Write("; }\r\n"); #line 46 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (property.HasSetter) { #line default #line hidden this.Write(" set \r\n {\r\n if ("); #line 49 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.FieldName)); #line default #line hidden this.Write(" != value)\r\n {\r\n "); #line 51 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(property.FieldName)); #line default #line hidden this.Write(" = value; \r\n RaisePropertyChanged();\r\n }\r\n }\r\n"); #line 55 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" }\r\n"); #line 57 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("\r\n"); #line 59 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 60 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (Model.HasAdditionalPropertiesType) { #line default #line hidden this.Write(" private System.Collections.Generic.IDictionary<string, "); #line 61 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.AdditionalPropertiesType)); #line default #line hidden this.Write("> _additionalProperties = new System.Collections.Generic.Dictionary<string, "); #line 61 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.AdditionalPropertiesType)); #line default #line hidden this.Write(">();\r\n\r\n [Newtonsoft.Json.JsonExtensionData]\r\n public System.Collections.Ge" + "neric.IDictionary<string, "); #line 64 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.AdditionalPropertiesType)); #line default #line hidden this.Write("> AdditionalProperties\r\n {\r\n get { return _additionalProperties; }\r\n " + " set { _additionalProperties = value; }\r\n }\r\n\r\n"); #line 70 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden #line 71 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (Model.Inpc) { #line default #line hidden this.Write(" public event System.ComponentModel.PropertyChangedEventHandler PropertyChange" + "d;\r\n\r\n"); #line 74 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write(" public string ToJson() \r\n {\r\n return Newtonsoft.Json.JsonConvert.Se" + "rializeObject(this"); #line 77 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.JsonSerializerParameterCode)); #line default #line hidden this.Write(");\r\n }\r\n \r\n public static "); #line 80 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(" FromJson(string data)\r\n {\r\n return Newtonsoft.Json.JsonConvert.Deseria" + "lizeObject<"); #line 82 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.Class)); #line default #line hidden this.Write(">(data"); #line 82 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Model.JsonSerializerParameterCode)); #line default #line hidden this.Write(");\r\n }\r\n"); #line 84 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" if (Model.Inpc) { #line default #line hidden this.Write(@" protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) { var handler = PropertyChanged; if (handler != null) handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } "); #line 92 "C:\Data\Projects\NJsonSchema\src\NJsonSchema.CodeGeneration.CSharp\Templates\ClassTemplate.tt" } #line default #line hidden this.Write("}"); return(this.GenerationEnvironment.ToString()); }