diff options
| author | Roy <roy.mail.net@gmail.com> | 2017-12-06 10:11:45 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2017-12-06 10:11:45 +0200 |
| commit | 3e665934f3f01b2cdd3de3fbc2c03ae27ac5740e (patch) | |
| tree | def622f54dff1dfc0820ed8fdd96edad98c05ec3 /Software/Visual_Studio/Tango.CodeGeneration | |
| parent | 3689238cb9ca77cbd7fa34dbd15003af87266e36 (diff) | |
| download | Tango-3e665934f3f01b2cdd3de3fbc2c03ae27ac5740e.tar.gz Tango-3e665934f3f01b2cdd3de3fbc2c03ae27ac5740e.zip | |
Moved ExtendedObject & RelayCommand to Core.
CodeGeneration EntityCodeFile working + cycle reference!
Diffstat (limited to 'Software/Visual_Studio/Tango.CodeGeneration')
6 files changed, 101 insertions, 22 deletions
diff --git a/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFile.cs b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFile.cs new file mode 100644 index 000000000..a6512dbee --- /dev/null +++ b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFile.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.CodeGeneration +{ + public class EntityCodeFile : Class + { + public String TableName { get; set; } + + public List<EntityCodeFileField> Fields { get; set; } + + public EntityCodeFile(String name) : base(name) + { + Fields = new List<EntityCodeFileField>(); + } + } + + public class EntityCodeFileField + { + public String Name { get; set; } + public String FieldName { get; set; } + public String Type { get; set; } + public String Description { get; set; } + public bool Construct { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.CodeGeneration/FilterGLCodeFile.cs b/Software/Visual_Studio/Tango.CodeGeneration/FilterGLCodeFile.cs deleted file mode 100644 index f560711d0..000000000 --- a/Software/Visual_Studio/Tango.CodeGeneration/FilterGLCodeFile.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.CodeGeneration -{ - public class FilterGLCodeFile : Class - { - public FilterGLCodeFile(String name) - : base(name) - { - - } - } -} diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Helper.cs b/Software/Visual_Studio/Tango.CodeGeneration/Helper.cs index 0ca012be9..2e0e449f1 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/Helper.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/Helper.cs @@ -30,12 +30,14 @@ namespace Tango.CodeGeneration public static String GetTemplate(String name) { var assembly = Assembly.GetAssembly(typeof(Helper)); - var resourceName = "CodeGenerator.Templates." + name + ".cshtml"; + var resourceName = typeof(Helper).Namespace + ".Templates." + name + ".cshtml"; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) - using (StreamReader reader = new StreamReader(stream)) { - return reader.ReadToEnd(); + using (StreamReader reader = new StreamReader(stream)) + { + return reader.ReadToEnd(); + } } } diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Tango.CodeGeneration.csproj b/Software/Visual_Studio/Tango.CodeGeneration/Tango.CodeGeneration.csproj index 989cfdf8d..e9f1fd586 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/Tango.CodeGeneration.csproj +++ b/Software/Visual_Studio/Tango.CodeGeneration/Tango.CodeGeneration.csproj @@ -47,6 +47,9 @@ <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Web" /> + <Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath> + </Reference> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> @@ -61,7 +64,7 @@ <Compile Include="CodeFile.cs" /> <Compile Include="CodeObject.cs" /> <Compile Include="DpProperty.cs" /> - <Compile Include="FilterGLCodeFile.cs" /> + <Compile Include="EntityCodeFile.cs" /> <Compile Include="Helper.cs" /> <Compile Include="ICodeObject.cs" /> <Compile Include="Method.cs" /> @@ -89,6 +92,7 @@ <ItemGroup> <None Include="packages.config" /> <EmbeddedResource Include="Templates\Namespace.cshtml" /> + <EmbeddedResource Include="Templates\EntityCodeFile.cshtml" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml new file mode 100644 index 000000000..301b9f58c --- /dev/null +++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using Tango.DAL.Remote.DB; + +namespace Tango.DAL.Remote.ObservableEntities +{ + public class @(Model.Name) : ObservableEntity<@(Model.TableName)> + { + @foreach (var prop in Model.Fields) + { + <div> + private @(prop.Type) _@(prop.Name.ToLower()); + /// <summary> + /// Gets or sets the @(Model.Name.ToLower()) @(prop.Description). + /// </summary> + [EntityFieldName("@(prop.FieldName)")] + public @(prop.Type) @(prop.Name) + { + get { return _@(prop.Name.ToLower()); } + set { _@(prop.Name.ToLower()) = value; RaisePropertyChanged(nameof(@(prop.Name))); } + } + </div> + } + + /// <summary> + /// Initializes a new instance of the <see cref="@(Model.Name)" /> class. + /// </summary> + public @(Model.Name)() : base() + { + Init(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="@(Model.Name)" /> class. + /// </summary> + /// <param name="entity">The entity.</param> + public @(Model.Name)(@(Model.TableName) entity) : base(entity) + { + Init(); + MapEntityToObservable(entity, this); + } + + /// <summary> + /// Initialize complex types. + /// </summary> + private void Init() + { + @foreach (var prop in Model.Fields) + { + if (prop.Construct) + { + <div> + @(prop.Name) = new @(prop.Type)(); + </div> + } + } + } + } +} diff --git a/Software/Visual_Studio/Tango.CodeGeneration/packages.config b/Software/Visual_Studio/Tango.CodeGeneration/packages.config index 341d85750..6de4c3ea0 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/packages.config +++ b/Software/Visual_Studio/Tango.CodeGeneration/packages.config @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net45" /> + <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" /> <package id="RazorEngine" version="3.10.0" targetFramework="net45" /> </packages>
\ No newline at end of file |
