Skip to content

Commit b1c3195

Browse files
committed
Angular added
Xml added Commands added Console renamed to CLI Standalone renamed to CLI.Standalone ASP .net Core support added
1 parent efb11ce commit b1c3195

File tree

74 files changed

+1059
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1059
-101
lines changed

Angular/AngularModule.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using KY.Core.Dependency;
2+
using KY.Core.Module;
3+
using KY.Generator.Command;
4+
5+
namespace KY.Generator.Angular
6+
{
7+
public class AngularModule : ModuleBase
8+
{
9+
public AngularModule(IDependencyResolver dependencyResolver)
10+
: base(dependencyResolver)
11+
{ }
12+
13+
public override void Initialize()
14+
{
15+
this.DependencyResolver.Bind<ICommandGenerator>().To<GenerateAngularConfig>();
16+
}
17+
}
18+
}

Angular/GenerateAngularConfig.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using KY.Core.Extension;
5+
using KY.Generator.Command;
6+
using KY.Generator.Templates;
7+
using KY.Generator.Templates.Extensions;
8+
9+
namespace KY.Generator.Angular
10+
{
11+
internal class GenerateAngularConfig : VariableCommandGenerator
12+
{
13+
public override string Command => "generate";
14+
public override string SubCommand => "angular-config";
15+
public override List<string> RequiredParameters => new List<string> { "url" };
16+
17+
protected override void OnGenerate(CommandConfiguration configuration, IList<FileTemplate> files)
18+
{
19+
this.GetTemplate("generator.json")
20+
.SetVariable("url", configuration.Parameters.GetValue("url"))
21+
.ToFile(false)
22+
.AddTo(files);
23+
}
24+
}
25+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{939AD578-2149-46E1-97D3-B83AEB15F3C4}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>KY.Generator.Angular</RootNamespace>
11+
<AssemblyName>KY.Generator.Angular</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="KY.Core.Common, Version=3.6.1510.0, Culture=neutral, processorArchitecture=MSIL">
35+
<HintPath>..\packages\KY.Core.Common.3.6.1510\lib\net40\KY.Core.Common.dll</HintPath>
36+
</Reference>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Net.Http" />
44+
<Reference Include="System.Xml" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Compile Include="AngularModule.cs" />
48+
<Compile Include="GenerateAngularConfig.cs" />
49+
<Compile Include="Properties\AssemblyInfo.cs" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<ProjectReference Include="..\Core\KY.Generator.Core.csproj">
53+
<Project>{30ec42aa-5c39-489a-b850-2c0ac64aef4f}</Project>
54+
<Name>KY.Generator.Core</Name>
55+
</ProjectReference>
56+
</ItemGroup>
57+
<ItemGroup>
58+
<None Include="KY.Generator.Angular.nuspec" />
59+
<EmbeddedResource Include="Templates\generator.json" />
60+
<None Include="packages.config" />
61+
</ItemGroup>
62+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
63+
</Project>

Console/KY.Generator.Console.nuspec renamed to Angular/KY.Generator.Angular.nuspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<description>$description$</description>
1414
<releaseNotes></releaseNotes>
1515
<copyright>Copyright 2018</copyright>
16-
<tags>KY Generator</tags>
16+
<tags>KY Generator Angular</tags>
17+
<dependencies>
18+
<dependency id="KY.Core.Common" version="3.6.1510" />
19+
<dependency id="KY.Generator.Core" version="0.7.1510" />
20+
</dependencies>
1721
</metadata>
1822
</package>

Angular/Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("KY.Generator.Angular")]
9+
[assembly: AssemblyDescription("Angular plugin for KY.Generator")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("KY-Programming")]
12+
[assembly: AssemblyProduct("KY.Generator.Angular")]
13+
[assembly: AssemblyCopyright("Copyright © 2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("939ad578-2149-46e1-97d3-b83aeb15f3c4")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("0.7.1510.0")]
36+
[assembly: AssemblyFileVersion("0.7.0.0")]

Angular/Templates/generator.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"Generator": {
3+
"Connection": "$url$/Generator",
4+
"VerifySsl": false
5+
},
6+
"Language": "TypeScript",
7+
"OData": {
8+
"Connection": "$url$/odata/$metadata",
9+
"SkipNamespace": true,
10+
"DataContext": {
11+
"RelativePath": "src\\models"
12+
},
13+
"Models": {
14+
"RelativePath": "src\\models"
15+
}
16+
}
17+
}

Angular/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="KY.Core.Common" version="3.6.1510" targetFramework="net452" />
4+
</packages>

AspDotNet/GeneratorGenerator.cs

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
4+
using KY.Generator.AspDotNet.Templates;
35
using KY.Generator.Configuration;
46
using KY.Generator.Csharp.Extensions;
57
using KY.Generator.Templates;
@@ -9,11 +11,16 @@ namespace KY.Generator.AspDotNet
911
{
1012
internal class GeneratorGenerator : IGenerator
1113
{
14+
private readonly List<ITemplate> templates;
15+
1216
public List<FileTemplate> Files { get; }
1317

1418
public GeneratorGenerator()
1519
{
1620
this.Files = new List<FileTemplate>();
21+
this.templates = new List<ITemplate>();
22+
this.templates.Add(new DotNetFrameworkTemplate());
23+
this.templates.Add(new DotNetCoreTemplate());
1724
}
1825

1926
public void Generate(ConfigurationBase configuration)
@@ -24,6 +31,7 @@ public void Generate(ConfigurationBase configuration)
2431
{
2532
return;
2633
}
34+
ITemplate template = this.templates.FirstOrDefault(x => x.Name == generator.Framework) ?? this.templates.First();
2735
if (generator.Controller != null)
2836
{
2937
if (configuration.Language != Csharp.Code.Language)
@@ -35,50 +43,92 @@ public void Generate(ConfigurationBase configuration)
3543
.AddClass("GeneratorController", Code.Type("Controller"))
3644
.WithUsing("System")
3745
.WithUsing("System.Linq")
38-
.WithUsing("System.Web.Mvc")
3946
.WithUsing("KY.Generator")
4047
.WithUsing("KY.Generator.Output");
4148

42-
MultilineCodeFragment createCode = classTemplate.AddMethod("Create", Code.Type("Guid"))
43-
.WithAttribute("ValidateInput", Code.Local("false"))
44-
.WithParameter(Code.Type("string"), "configuration")
45-
.Code;
49+
classTemplate.Usings.AddRange(template.Usings);
50+
51+
if (template.UseOwnCache)
52+
{
53+
GenericTypeTemplate type = Code.Generic("Dictionary", Code.Type("string"), Code.Type("MemoryOutput"));
54+
classTemplate.AddField("cache", type)
55+
.Static()
56+
.DefaultValue = Code.New(type);
57+
}
58+
59+
MethodTemplate createMethode = classTemplate.AddMethod("Create", Code.Type("Guid"))
60+
.WithParameter(Code.Type("string"), "configuration");
61+
if (!template.ValidateInput)
62+
{
63+
createMethode.WithAttribute("ValidateInput", Code.Local("false"));
64+
}
65+
66+
MethodTemplate commandMethode = classTemplate.AddMethod("Command", Code.Type("Guid"))
67+
.WithParameter(Code.Type("string"), "command");
68+
69+
MultilineCodeFragment createCode = createMethode.Code;
4670
createCode.AddLine(Code.Declare(Code.Type("Guid"), "id", Code.Local("Guid").Method("NewGuid")))
4771
.AddLine(Code.Declare(Code.Type("MemoryOutput"), "output", Code.New(Code.Type("MemoryOutput"))))
4872
.AddLine(Code.Declare(Code.Type("Generator"), "generator", Code.New(Code.Type("Generator"))))
4973
.AddLine(Code.Local("generator").Method("SetOutput", Code.Local("output")));
74+
MultilineCodeFragment commandCode = commandMethode.Code;
75+
commandCode.AddLine(Code.Declare(Code.Type("Guid"), "id", Code.Local("Guid").Method("NewGuid")))
76+
.AddLine(Code.Declare(Code.Type("MemoryOutput"), "output", Code.New(Code.Type("MemoryOutput"))))
77+
.AddLine(Code.Declare(Code.Type("Generator"), "generator", Code.New(Code.Type("Generator"))))
78+
.AddLine(Code.Local("generator").Method("SetOutput", Code.Local("output")));
5079
foreach (string nameSpace in generator.Controller.Usings)
5180
{
5281
classTemplate.AddUsing(nameSpace);
5382
}
5483
foreach (string moduleType in generator.Controller.PreloadModules)
5584
{
5685
createCode.AddLine(Code.Local("generator").GenericMethod("PreloadModule", Code.Type(moduleType)));
86+
commandCode.AddLine(Code.Local("generator").GenericMethod("PreloadModule", Code.Type(moduleType)));
5787
}
5888
foreach (GeneratorConfigurationConfigureModule configure in generator.Controller.Configures)
5989
{
6090
createCode.AddLine(Code.Local("generator").Method(configure.Module, Code.Lambda("x", Csharp.Code.Csharp("x." + configure.Action))));
91+
commandCode.AddLine(Code.Local("generator").Method(configure.Module, Code.Lambda("x", Csharp.Code.Csharp("x." + configure.Action))));
6192
}
6293
createCode.AddLine(Code.Local("generator").Method("ParseConfiguration", Code.Local("configuration")))
6394
.AddLine(Code.Local("generator").Method("Run"))
64-
.AddBlankLine()
65-
.AddLine(Code.This().Property("HttpContext").Property("Cache").Index(Code.Local("id").Method("ToString")).Assign(Code.Local("output")))
66-
.AddLine(Code.Return(Code.Local("id")));
95+
.AddBlankLine();
96+
commandCode.AddLine(Code.Local("generator").Method("ParseCommand", Code.Local("command")))
97+
.AddLine(Code.Local("generator").Method("Run"))
98+
.AddBlankLine();
99+
if (template.UseOwnCache)
100+
{
101+
createCode.AddLine(Code.Local("cache").Index(Code.Local("id").Method("ToString")).Assign(Code.Local("output")));
102+
commandCode.AddLine(Code.Local("cache").Index(Code.Local("id").Method("ToString")).Assign(Code.Local("output")));
103+
}
104+
else
105+
{
106+
createCode.AddLine(Code.This().Property("HttpContext").Property("Cache").Index(Code.Local("id").Method("ToString")).Assign(Code.Local("output")));
107+
commandCode.AddLine(Code.This().Property("HttpContext").Property("Cache").Index(Code.Local("id").Method("ToString")).Assign(Code.Local("output")));
108+
}
109+
createCode.AddLine(Code.Return(Code.Local("id")));
110+
commandCode.AddLine(Code.Return(Code.Local("id")));
67111

112+
ChainedCodeFragment getFromCacheForFilesFragment = template.UseOwnCache
113+
? (ChainedCodeFragment)Code.Local("cache")
114+
: Code.This().Property("HttpContext").Property("Cache");
68115
classTemplate.AddMethod("GetFiles", Code.Type("string"))
69116
.WithParameter(Code.Type("string"), "id")
70117
.Code.AddLine(Code.If(Code.Local("id").Equals().Null(), x => x.Code.AddLine(Code.Return(Code.Null()))))
71-
.AddLine(Code.Declare(Code.Type("MemoryOutput"), "output", Code.This().Property("HttpContext").Property("Cache").Index(Code.Local("id")).As(Code.Type("MemoryOutput"))))
118+
.AddLine(Code.Declare(Code.Type("MemoryOutput"), "output", getFromCacheForFilesFragment.Index(Code.Local("id")).As(Code.Type("MemoryOutput"))))
72119
.AddLine(Code.Return(Code.InlineIf(Code.Local("output").Equals().Null(),
73120
Code.Null(),
74121
Code.Local("string").Method("Join", Code.Local("Environment").Property("NewLine"),
75122
Code.Local("output").Property("Files").Method("Select", Code.Lambda("x", Code.Local("x").Property("Key")))))));
76123

124+
ChainedCodeFragment getFromCacheForFileFragment = template.UseOwnCache
125+
? (ChainedCodeFragment)Code.Local("cache")
126+
: Code.This().Property("HttpContext").Property("Cache");
77127
classTemplate.AddMethod("GetFile", Code.Type("string"))
78128
.WithParameter(Code.Type("string"), "id")
79129
.WithParameter(Code.Type("string"), "path")
80130
.Code.AddLine(Code.If(Code.Local("id").Equals().Null(), x => x.Code.AddLine(Code.Return(Code.Null()))))
81-
.AddLine(Code.Declare(Code.Type("MemoryOutput"), "output", Code.This().Property("HttpContext").Property("Cache").Index(Code.Local("id")).As(Code.Type("MemoryOutput"))))
131+
.AddLine(Code.Declare(Code.Type("MemoryOutput"), "output", getFromCacheForFileFragment.Index(Code.Local("id")).As(Code.Type("MemoryOutput"))))
82132
.AddLine(Code.Return(Code.InlineIf(Code.Local("output").Equals().Null().Or().Not().Local("output").Property("Files").Method("ContainsKey", Code.Local("path")),
83133
Code.Null(),
84134
Code.Local("output").Property("Files").Index(Code.Local("path")))));

AspDotNet/KY.Generator.AspDotNet.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="KY.Core.Common, Version=3.6.1486.0, Culture=neutral, processorArchitecture=MSIL">
35-
<HintPath>..\packages\KY.Core.Common.3.6.1486\lib\net40\KY.Core.Common.dll</HintPath>
34+
<Reference Include="KY.Core.Common, Version=3.6.1510.0, Culture=neutral, processorArchitecture=MSIL">
35+
<HintPath>..\packages\KY.Core.Common.3.6.1510\lib\net40\KY.Core.Common.dll</HintPath>
3636
</Reference>
3737
<Reference Include="System" />
3838
<Reference Include="System.Core" />
@@ -55,6 +55,9 @@
5555
<Compile Include="GeneratorConfigurationReader.cs" />
5656
<Compile Include="GeneratorGenerator.cs" />
5757
<Compile Include="Properties\AssemblyInfo.cs" />
58+
<Compile Include="Templates\DotNetCoreTemplate.cs" />
59+
<Compile Include="Templates\DotNetFrameworkTemplate.cs" />
60+
<Compile Include="Templates\ITemplate.cs" />
5861
</ItemGroup>
5962
<ItemGroup>
6063
<ProjectReference Include="..\Core\KY.Generator.Core.csproj">

AspDotNet/KY.Generator.AspDotNet.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<copyright>Copyright 2018</copyright>
1616
<tags>KY Generator ASP.net</tags>
1717
<dependencies>
18-
<dependency id="KY.Core.Common" version="3.6.1486" />
19-
<dependency id="KY.Generator.Core" version="0.7.1480" />
18+
<dependency id="KY.Core.Common" version="3.6.1510" />
19+
<dependency id="KY.Generator.Core" version="0.7.1510" />
2020
<dependency id="KY.Generator.Csharp" version="0.7.1480" />
2121
</dependencies>
2222
</metadata>

0 commit comments

Comments
 (0)