Parcourir la source

Add Infrastructure in initial version (v1.0.0.0), not nugeted yet

Dalibor Votruba il y a 6 ans
Parent
commit
210a13f113

+ 7 - 3
@Workbench/@Workbench.csproj

@@ -33,6 +33,9 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="QDR.FND.Common, Version=1.0.0.7, Culture=neutral, PublicKeyToken=60b8fdcb29a015db, processorArchitecture=MSIL">
+      <HintPath>..\Infrastructure\packages\Quadarax.Foundation.Common.1.0.0.7\lib\net472\QDR.FND.Common.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
@@ -48,11 +51,12 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="App.config" />
+    <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\Common\Common.csproj">
-      <Project>{6d9348fb-8c3d-4dfd-949b-414fc6bf2a22}</Project>
-      <Name>Common</Name>
+    <ProjectReference Include="..\Infrastructure\Infrastructure.csproj">
+      <Project>{9b070374-98a3-4122-85dd-cf5ab5e4b503}</Project>
+      <Name>Infrastructure</Name>
     </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 1 - 8
@Workbench/Program.cs

@@ -1,9 +1,4 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Quadarax.Foundation.Common.Security;
 
 namespace _Workbench
 {
@@ -11,9 +6,7 @@ namespace _Workbench
     {
         static void Main(string[] args)
         {
-            var plain = "foforotopo";
-            var result = Secure.Encrypt(plain);
-            Console.WriteLine(result);
+         
         }
     }
 }

+ 4 - 0
@Workbench/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Quadarax.Foundation.Common" version="1.0.0.7" targetFramework="net472" />
+</packages>

+ 6 - 0
Infrastructure/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+    </startup>
+</configuration>

+ 31 - 0
Infrastructure/GlobalContainer.cs

@@ -0,0 +1,31 @@
+using System;
+using log4net;
+using Quadarax.Foundation.Common.Object.Bee.Core.Pattern;
+using Quadarax.Foundation.Infrastructure.Layers;
+
+namespace Quadarax.Foundation.Infrastructure
+{
+    internal class GlobalContainer : Singleton<GlobalContainer>
+    {
+
+        private GlobalLayer _global;
+        private ILog _logger;
+
+        public GlobalLayer RootLayer => _global;
+
+        public GlobalContainer()
+        {
+            _logger = LogManager.GetLogger(GetType());
+        }
+
+        public void CreateGlobal<TGlobalLayer>(string globalLayerName) where TGlobalLayer : GlobalLayer, new()
+        {
+            _global = (GlobalLayer) Activator.CreateInstance(typeof(TGlobalLayer), globalLayerName);
+        }
+
+        public string Dump()
+        {
+            return _global.Dump();
+        }
+    }
+}

+ 10 - 0
Infrastructure/IModule.cs

@@ -0,0 +1,10 @@
+using Quadarax.Foundation.Infrastructure.Layers;
+
+namespace Quadarax.Foundation.Infrastructure
+{
+    public interface IModule
+    {
+        string GetModuleName();
+        LayerClassificationEnum Layer { get; }
+    }
+}

+ 37 - 0
Infrastructure/Infra.cs

@@ -0,0 +1,37 @@
+using System;
+using log4net;
+using Quadarax.Foundation.Infrastructure.Layers;
+
+namespace Quadarax.Foundation.Infrastructure
+{
+    public static class Infra
+    {
+
+        private static ILog _logger = LogManager.GetLogger(typeof(Infra));
+
+        public static bool IsInitialized { get; private set; }
+
+        public static void Initialize<TGlobalLayer>(string globalLayerName) where TGlobalLayer : GlobalLayer, new()
+        {
+            if (IsInitialized)
+                throw new InvalidOperationException("Infrastructure is already initialized!");
+
+            GlobalContainer.Instance.CreateGlobal<TGlobalLayer>(globalLayerName);
+            IsInitialized = true;
+        }
+
+        public static TModule Get<TModule>() where TModule : IModule
+        {
+            if (!IsInitialized)
+                throw new InvalidOperationException("Infrastructure is not initialized! Call Infra.Initialize first!");
+            return GlobalContainer.Instance.RootLayer.Get<TModule>();
+        }
+
+        public static string Dump()
+        {
+            if (!IsInitialized)
+                return "Not initialized!";
+            return GlobalContainer.Instance.Dump();
+        }
+    }
+}

+ 85 - 0
Infrastructure/Infrastructure.csproj

@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{9B070374-98A3-4122-85DD-CF5AB5E4B503}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>Quadarax.Foundation.Infrastructure</RootNamespace>
+    <AssemblyName>QDR.FND.Infrastructure</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationIcon>quadarax_dll.ico</ApplicationIcon>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
+      <HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
+    </Reference>
+    <Reference Include="QDR.FND.Common, Version=1.0.0.7, Culture=neutral, PublicKeyToken=60b8fdcb29a015db, processorArchitecture=MSIL">
+      <HintPath>packages\Quadarax.Foundation.Common.1.0.0.7\lib\net472\QDR.FND.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="StructureMap, Version=4.7.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>packages\StructureMap.4.7.1\lib\net45\StructureMap.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="GlobalContainer.cs" />
+    <Compile Include="IModule.cs" />
+    <Compile Include="Infra.cs" />
+    <Compile Include="Layers\BusinessLayer.cs" />
+    <Compile Include="Layers\DataLayer.cs" />
+    <Compile Include="Layers\GlobalLayer.cs" />
+    <Compile Include="Layers\Layer.cs" />
+    <Compile Include="Layers\LayerClassificationEnum.cs" />
+    <Compile Include="Layers\PresentationLayer.cs" />
+    <Compile Include="Layers\ServiceLayer.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="create_package.ps1" />
+    <None Include="packages.config" />
+    <None Include="QDR.FND.Infrastructure.nuspec" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="quadarax_dll.ico" />
+    <Content Include="ReleaseNote.txt" />
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 31 - 0
Infrastructure/Infrastructure.sln

@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.960
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "Infrastructure.csproj", "{9B070374-98A3-4122-85DD-CF5AB5E4B503}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "@Workbench", "..\@Workbench\@Workbench.csproj", "{60DDDF9B-507A-4665-8A5B-1F670005727F}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{9B070374-98A3-4122-85DD-CF5AB5E4B503}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{9B070374-98A3-4122-85DD-CF5AB5E4B503}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{9B070374-98A3-4122-85DD-CF5AB5E4B503}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{9B070374-98A3-4122-85DD-CF5AB5E4B503}.Release|Any CPU.Build.0 = Release|Any CPU
+		{60DDDF9B-507A-4665-8A5B-1F670005727F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{60DDDF9B-507A-4665-8A5B-1F670005727F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{60DDDF9B-507A-4665-8A5B-1F670005727F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{60DDDF9B-507A-4665-8A5B-1F670005727F}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {ACCB019A-2EC7-4245-8C45-42A3A06BBF53}
+	EndGlobalSection
+EndGlobal

+ 10 - 0
Infrastructure/Layers/BusinessLayer.cs

@@ -0,0 +1,10 @@
+namespace Quadarax.Foundation.Infrastructure.Layers
+{
+    public abstract class BusinessLayer : Layer
+    {
+        protected BusinessLayer(string name) : base(name)
+        {
+            LayerType = LayerClassificationEnum.Business;
+        }
+    }
+}

+ 10 - 0
Infrastructure/Layers/DataLayer.cs

@@ -0,0 +1,10 @@
+namespace Quadarax.Foundation.Infrastructure.Layers
+{
+    public abstract class DataLayer : Layer
+    {
+        protected DataLayer(string name) : base(name)
+        {
+            LayerType = LayerClassificationEnum.Data;
+        }
+    }
+}

+ 10 - 0
Infrastructure/Layers/GlobalLayer.cs

@@ -0,0 +1,10 @@
+namespace Quadarax.Foundation.Infrastructure.Layers
+{
+    public abstract class GlobalLayer : Layer
+    {
+        protected GlobalLayer(string name) : base(name)
+        {
+            LayerType = LayerClassificationEnum.Global;
+        }
+    }
+}

+ 86 - 0
Infrastructure/Layers/Layer.cs

@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using log4net;
+using Quadarax.Foundation.Common.Object;
+using StructureMap;
+
+namespace Quadarax.Foundation.Infrastructure.Layers
+{
+    public abstract class Layer : DisposableObject
+    {
+        private IContainer _container;
+        private IList<Layer> _childLayers = new List<Layer>();
+        private Layer _parentLayer;
+
+        protected ILog Log { get; }
+
+        public string Name { get; }
+
+        public int ChildLayersCount => _childLayers.Count;
+
+        public LayerClassificationEnum LayerType { get; protected set; }
+
+        protected Layer(string name, Layer parentLayer = null)
+        {
+            if (string.IsNullOrEmpty(name))
+                throw new ArgumentNullException(nameof(name), "Infrastucture layer must have a name.");
+            _parentLayer = parentLayer;
+
+            Log = LogManager.GetLogger(GetType());
+            Name = name;
+
+            InitializeInternal();
+
+            Log.Info($"Layer '{Name}' fully created.");
+        }
+
+
+        private void InitializeInternal()
+        {
+            _container = _parentLayer == null ? new Container() : _parentLayer._container.CreateChildContainer();
+            OnModuleRegistry(_container);
+            OnLayerRegistry();
+            Log.Info($"Layer '{Name}' initialization done");
+        }
+
+        protected abstract void OnLayerRegistry();
+        
+        protected abstract void OnModuleRegistry(IContainer container);
+
+        protected override void OnDisposing()
+        {
+            _parentLayer?.Dispose();
+            _parentLayer = null;
+
+            if (_childLayers != null)
+            {
+                foreach (var layer in _childLayers)
+                {
+                    layer.Dispose();
+                }
+            }
+
+            Log.Info($"Layer '{Name}' disposed.");
+        }
+
+        public TModule Get<TModule>() where TModule : IModule
+        {
+            return _container.GetInstance<TModule>();
+        }
+
+        public string Dump()
+        {
+            var sb = new StringBuilder();
+            sb.Append("*** Layer: ").Append(Name).Append(" [").Append(LayerType).Append("] * BEGIN ***").AppendLine();
+            sb.Append("Parent:").AppendLine();
+            sb.Append(_parentLayer == null ? "none" : _parentLayer.Name);
+            sb.AppendLine();
+            sb.Append("Childs:").AppendLine();
+            foreach (var child in _childLayers)
+                sb.Append(child.Dump()).AppendLine();
+            sb.Append("*** Layer: ").Append(Name).Append(" [").Append(LayerType).Append("] * END ***").AppendLine();
+            return sb.ToString();
+        }
+    }
+}

+ 11 - 0
Infrastructure/Layers/LayerClassificationEnum.cs

@@ -0,0 +1,11 @@
+namespace Quadarax.Foundation.Infrastructure.Layers
+{
+    public enum  LayerClassificationEnum
+    {
+        Data,
+        Business,
+        Presentation,
+        Service,
+        Global
+    }
+}

+ 11 - 0
Infrastructure/Layers/PresentationLayer.cs

@@ -0,0 +1,11 @@
+namespace Quadarax.Foundation.Infrastructure.Layers
+{
+    public abstract class PresentationLayer : Layer
+    {
+
+        protected PresentationLayer(string name) : base(name)
+        {
+            LayerType = LayerClassificationEnum.Presentation;
+        }
+    }
+}

+ 10 - 0
Infrastructure/Layers/ServiceLayer.cs

@@ -0,0 +1,10 @@
+namespace Quadarax.Foundation.Infrastructure.Layers
+{
+    public abstract class ServiceLayer : Layer
+    {
+        protected ServiceLayer(string name) : base(name)
+        {
+            LayerType = LayerClassificationEnum.Service;
+        }
+    }
+}

+ 36 - 0
Infrastructure/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("QDR.FND.Infrastructure")]
+[assembly: AssemblyDescription("Infrastructure - simple component model patterns (part of Quadarax.Foundation)")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Quadarax")]
+[assembly: AssemblyProduct("Quadarax.Foundation")]
+[assembly: AssemblyCopyright("Copyright © Quadarax 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("9b070374-98a3-4122-85dd-cf5ab5e4b503")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 34 - 0
Infrastructure/QDR.FND.Infrastructure.nuspec

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<package>
+  <metadata>
+    <id>Quadarax.Foundation.Infrastructure</id>
+    <version>1.0.0.0</version>
+    <title>Quadarax.Foundation.Infrastructure</title>
+    <authors>Dalibor Votruba, Quadarax</authors>
+    <owners>Dalibor Votruba</owners>
+    <projectUrl>https://project.quadarax.com/</projectUrl>
+    <iconUrl>http://project.quadarax.com/favicon.ico</iconUrl>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <description>Implementations of simple infrastructure patterns (Component model).</description>
+    <releaseNotes>
+      28.12.2019 v.1.0.0.0
+      New
+      - Initial version
+    </releaseNotes>
+    <copyright>Copyright (c) 2020 Quadarax</copyright>
+    <tags>quadarax, foundation, infrastructure, component model, qdr, fnd, library</tags>
+    <dependencies>
+      <group targetFramework="net472">
+        <dependency id="Quadarax.Foundation.Common" version="1.0.0.7"  />
+        <dependency id="log4net" version="2.0.8"  />
+        <dependency id="StructureMap" version="4.7.1" />
+      </group>
+    </dependencies>
+    <summary>Libraries</summary>
+  </metadata>
+  <files>
+    <file src="ReleaseNote.txt" />
+    <file src="bin\Release\QDR.FND.Common.dll" target="lib\net472\QDR.FND.Common.dll" />
+	  <file src="bin\Release\QDR.FND.Common.pdb" target="lib\net472\QDR.FND.Common.pdb" />
+  </files>
+</package>

+ 3 - 0
Infrastructure/ReleaseNote.txt

@@ -0,0 +1,3 @@
+28.12.2019 v.1.0.0.0
+New
+ - Initial version

+ 17 - 0
Infrastructure/create_package.ps1

@@ -0,0 +1,17 @@
+# Generate Nuget package from this folder (find *.nuspec files at this level)
+
+
+# Set up initial variables, paths, constants
+Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted
+Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
+$nuget = "$env:LOCALAPPDATA\Nuget\Nuget.exe"
+$current = (Get-Location).Path
+Set-Alias nuget $nuget
+
+$nuspecFiles = Get-ChildItem -Path $current | Where-Object {
+    $_.FullName -like "*.nuspec"} | Select-Object
+	
+foreach($file in $nuspecFiles){
+    nuget pack $file.FullName
+	Write-Host ("Generated nuget package from {0}" -f $file.FullName) -ForegroundColor White
+}	

+ 7 - 0
Infrastructure/packages.config

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="log4net" version="2.0.8" targetFramework="net472" />
+  <package id="Quadarax.Foundation.Common" version="1.0.0.7" targetFramework="net472" />
+  <package id="StructureMap" version="4.7.1" targetFramework="net472" />
+  <package id="System.Reflection.Emit.Lightweight" version="4.3.0" targetFramework="net472" />
+</packages>

BIN
Infrastructure/quadarax_dll.ico


BIN
Infrastructure/quadarax_strong_name_key.pfx