private void createPOCOClassProperties(TypeStructure typeStructure) { var properties = (List <IJSProperty>)jsProperties; foreach (var property in typeStructure.Properties) { var jsProperty = JSBuilderIOCContainer.Instance.CreateProperty(); jsProperty.Comment = JSBuilderIOCContainer.Instance.CreateComment(); jsProperty.Name = property.Name; jsProperty.Comment.Type = JSTypeMapping.GetJSType(property); jsProperty.Assignable = JSBuilderIOCContainer.Instance.CreateAssignable(); if (property.IsSytemType) { jsProperty.Assignable.ObjectAssignment = $"typeof(data.{property.Name}) !== \"undefined\" ? data.{property.Name} : null"; } else { if (property.IsArray) { jsProperty.Assignable.ObjectAssignment = $"typeof(data.{property.Name}) !== \"undefined\" ? data.{property.Name}.map(function(dataRow){{ return new {property.Name}(dataRow);}}) : null"; } else { jsProperty.Assignable.ObjectAssignment = $"typeof(data.{property.Name}) !== \"undefined\" ? new {property.Name}(dataRow) : null"; } } properties.Add(jsProperty); } }
public PropertyComment(TypeStructure typeStructure) : base("PropertyComment") { var jsType = JSTypeMapping.GetJSType(typeStructure); base.tagValues = new Dictionary <string, string> { { typeTag, jsType.JSTypeDef } }; }
public RunMethodRequest(MethodStructure methodStructure) : base(Resources.runRequestMethod) { Name = methodStructure.IsRPC ? methodStructure.Name : NamingHelpers.GetRestfullMethodName(methodStructure); Comment = JSBuilderIOCContainer.Instance.CreateComment(); Comment.Description = $"Method to invoke request to {methodStructure.URL}. Method: {HttpHelpers.GetHTTPMethod(methodStructure)}."; Comment.Params = methodStructure.Parameters.ToDictionary(k => k.Name, v => JSTypeMapping.GetJSType(v)); Comment.ReturnType = JSTypeMapping.GetJSType(methodStructure.Result); Comment.ReturnType.IsPromise = true; Parameters = methodStructure.Parameters.Select(x => x.Name).ToList(); }
public RunRequestMethodComment(MethodStructure methodStructure) : base("RunRequestMethodComment") { tagValues = new Dictionary <string, string> { { descriptionTag, Configuration.Instance.Comments.RequestMethod(HttpHelpers.GetHTTPMethod(methodStructure), methodStructure.URL) }, { resultTypeTag, JSTypeMapping.GetJSType(methodStructure.Result, true).JSTypeDef } }; multiplyTags(methodStructure.Parameters.Count, ((JSRenderble)DI.Get <IParameterTypeComment>()).Name); methodStructure.Parameters.ForEach(parameter => childRenderbles.Add((JSRenderble)DI.Get <IParameterTypeComment>(JSTypeMapping.GetJSType(parameter), parameter.Name)) ); }
private void createPOCOClassProperties(TypeStructure typeStructure) { var properties = (List <IJSProperty>)jsProperties; foreach (var property in typeStructure.Properties) { var jsProperty = JSBuilderIOCContainer.Instance.CreateProperty(); jsProperty.Comment = JSBuilderIOCContainer.Instance.CreateComment(); jsProperty.Name = property.Name; jsProperty.Comment.Type = JSTypeMapping.GetJSType(property); jsProperty.Assignable = JSBuilderIOCContainer.Instance.CreateAssignable(); if (property.IsSytemType) { jsProperty.Assignable.ObjectAssignment = $"typeof(data.{property.Name}) !== \"undefined\" ? data.{property.Name} : null"; } else { if (property.IsArray) { jsProperty.Assignable.ObjectAssignment = $"typeof(data.{property.Name}) !== \"undefined\" ? data.{property.Name}.map(dataRow => new {property.Name}(dataRow)) : null"; } else { jsProperty.Assignable.ObjectAssignment = $"typeof(data.{property.Name}) !== \"undefined\" ? new {property.Name}(dataRow) : null"; } } properties.Add(jsProperty); if (!property.IsSytemType) { var import = JSBuilderIOCContainer.Instance.CreateImport(); import.Modules = new string[] { property.TypeName }; import.URL = $"./{property.TypeName}.js"; ((List <IImport>)Imports).Add(import); } } }
private void buildFromObjectAssignmentProperties(TypeStructure typeStructure) { multiplyTags(typeStructure.Properties.Count, getFromObjectPropertyTagName(typeStructure)); childRenderbles.AddRange(typeStructure.Properties.Select(property => (JSRenderble)DI.Get <IFromObjectAssignmentProperty>(property, JSTypeMapping.GetJSType(property)))); }
public ClassConstructorComment(TypeStructure typeStructure) : base("ClassConstructorComment") { base.tagValues = new Dictionary <string, string> { { descriptionTag, Configuration.Instance.Comments.ResultClassDescription(Configuration.Instance.ModelsNameFactory(typeStructure.TypeName)) } }; multiplyTags(typeStructure.Properties.Count, ((JSRenderble)DI.Get <IParameterTypeComment>(new JSString(), "")).Name); typeStructure.Properties.ForEach(property => childRenderbles.Add((JSRenderble)DI.Get <IParameterTypeComment>(JSTypeMapping.GetJSType(property), property.Name))); }