|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Text; |
| 4 | +using CodeGen.JsonTypes; |
| 5 | + |
| 6 | +namespace CodeGen.Generators.NanoFrameworkGen |
| 7 | +{ |
| 8 | + class ProjectGenerator: GeneratorBase |
| 9 | + { |
| 10 | + private readonly Quantity _quantity; |
| 11 | + |
| 12 | + public ProjectGenerator(Quantity quantity) |
| 13 | + { |
| 14 | + _quantity = quantity ?? throw new ArgumentNullException(nameof(quantity)); |
| 15 | + } |
| 16 | + |
| 17 | + public override string Generate() |
| 18 | + { |
| 19 | + Writer.WL($@"<?xml version=""1.0"" encoding=""utf-8""?> |
| 20 | +<Project ToolsVersion=""15.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""> |
| 21 | + <PropertyGroup Label=""Globals""> |
| 22 | + <NanoFrameworkProjectSystemPath>$(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath> |
| 23 | + </PropertyGroup> |
| 24 | + <Import Project=""$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props"" Condition=""Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')"" /> |
| 25 | + <PropertyGroup> |
| 26 | + <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration> |
| 27 | + <Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform> |
| 28 | + <ProjectTypeGuids>{{11A8DD76-328B-46DF-9F39-F559912D0360}};{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}</ProjectTypeGuids> |
| 29 | + <ProjectGuid>{{{Guid.NewGuid()}}}</ProjectGuid> |
| 30 | + <OutputType>Library</OutputType> |
| 31 | + <AppDesignerFolder>Properties</AppDesignerFolder> |
| 32 | + <FileAlignment>512</FileAlignment> |
| 33 | + <RootNamespace>UnitsNet</RootNamespace> |
| 34 | + <AssemblyName>UnitsNet.{_quantity.Name}</AssemblyName> |
| 35 | + <TargetFrameworkVersion>v1.0</TargetFrameworkVersion> |
| 36 | + <DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile> |
| 37 | + </PropertyGroup> |
| 38 | + <Import Project=""$(NanoFrameworkProjectSystemPath)NFProjectSystem.props"" Condition=""Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')"" /> |
| 39 | + <ItemGroup> |
| 40 | + <Compile Include=""..\Quantities\{_quantity.Name}.g.cs"" /> |
| 41 | + <Compile Include=""..\Units\{_quantity.Name}Unit.g.cs"" /> |
| 42 | + <Compile Include=""..\Properties\AssemblyInfo.cs"" /> |
| 43 | + </ItemGroup> |
| 44 | + <ItemGroup> |
| 45 | + <Reference Include=""mscorlib, Version={NanoFrameworkGenerator.MscorlibVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731""> |
| 46 | + <HintPath>..\packages\nanoFramework.CoreLibrary.{NanoFrameworkGenerator.MscorlibNuGetVersion}\lib\mscorlib.dll</HintPath> |
| 47 | + <Private>True</Private> |
| 48 | + <SpecificVersion>True</SpecificVersion> |
| 49 | + </Reference>"); |
| 50 | + |
| 51 | + if(NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name)) |
| 52 | + { |
| 53 | + Writer.WL($@" |
| 54 | + <Reference Include=""System.Math, Version={NanoFrameworkGenerator.MathVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731""> |
| 55 | + <HintPath>..\packages\nanoFramework.System.Math.{NanoFrameworkGenerator.MathNuGetVersion}\lib\System.Math.dll</HintPath> |
| 56 | + <Private>True</Private> |
| 57 | + <SpecificVersion>True</SpecificVersion> |
| 58 | + </Reference>"); |
| 59 | + } |
| 60 | + |
| 61 | + Writer.WL(@" |
| 62 | + </ItemGroup> |
| 63 | + <ItemGroup> |
| 64 | + <None Include=""packages.config"" /> |
| 65 | + </ItemGroup> |
| 66 | + <Import Project=""$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets"" Condition=""Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')"" /> |
| 67 | + <ProjectExtensions> |
| 68 | + <ProjectCapabilities> |
| 69 | + <ProjectConfigurationsDeclaredAsItems /> |
| 70 | + </ProjectCapabilities> |
| 71 | + </ProjectExtensions> |
| 72 | +</Project>"); |
| 73 | + |
| 74 | + return Writer.ToString(); |
| 75 | + } |
| 76 | + } |
| 77 | +} |
0 commit comments