Browse Source

Common:

Add string name, add icon, change target framework to 4.7.2
Dalibor Votruba 6 years ago
parent
commit
4040850d85

+ 11 - 0
Common/Common.csproj

@@ -30,6 +30,15 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationIcon>quadarax_dll.ico</ApplicationIcon>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>quadarax_strong_name_key.pfx</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Core" />
@@ -54,6 +63,7 @@
   </ItemGroup>
   <ItemGroup />
   <ItemGroup>
+    <Content Include="quadarax_dll.ico" />
     <Content Include="ReleaseNote.txt" />
   </ItemGroup>
   <ItemGroup>
@@ -61,6 +71,7 @@
     <None Include="QDR.FND.Common.nuspec">
       <SubType>Designer</SubType>
     </None>
+    <None Include="quadarax_strong_name_key.pfx" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

BIN
Common/quadarax_dll.ico


BIN
Common/quadarax_strong_name_key.pfx


+ 3 - 3
QConsole/QConsole.DevBench/App.config

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

+ 1 - 0
QConsole/QConsole.DevBench/Command/Entry.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Quadarax.Foundation.Common.Reflection;
 using Quadarax.Foundation.QConsole.Command.Base;
 using Quadarax.Foundation.QConsole.Extensions;
 

+ 1 - 0
QConsole/QConsole.DevBench/Command/Test2Cmd.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Quadarax.Foundation.Common.Value;
 using Quadarax.Foundation.QConsole.Attributes;
 using Quadarax.Foundation.QConsole.Command;
 using Quadarax.Foundation.QConsole.Command.Base;

+ 3 - 1
QConsole/QConsole.DevBench/Command/TestCmd.cs

@@ -1,4 +1,6 @@
-using Quadarax.Foundation.QConsole.Attributes;
+using Quadarax.Foundation.Common.Console;
+using Quadarax.Foundation.Common.Value;
+using Quadarax.Foundation.QConsole.Attributes;
 using Quadarax.Foundation.QConsole.Command;
 using Quadarax.Foundation.QConsole.Command.Base;
 

+ 1 - 0
QConsole/QConsole.DevBench/Program.cs

@@ -15,6 +15,7 @@ namespace Quadarax.Foundation.QConsole.DevBench
             //Console.ReadLine();
             var config = new StartupConfiguration("MyTestConsole", Version.Parse("1.0.0"));
             config.AllowInteractive = false;
+            config.WaitOnKeyInNonInteractiveMode = true;
             config.CommandDefinitionAssebmly = new Assembly[]{Assembly.GetEntryAssembly()};
             config.DisableDefaultCommands = true;
 

+ 6 - 1
QConsole/QConsole.DevBench/QConsole.DevBench.csproj

@@ -8,10 +8,11 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Quadarax.Foundation.QConsole.DevBench</RootNamespace>
     <AssemblyName>QDR.FND.QConsole.DevBench</AssemblyName>
-    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,6 +34,9 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="QDR.FND.Common, Version=1.0.0.5, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\Quadarax.Foundation.Common.1.0.0.5\lib\net472\QDR.FND.Common.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
@@ -51,6 +55,7 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="App.config" />
+    <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\QConsole\QDR.FND.QConsole.csproj">

+ 4 - 0
QConsole/QConsole.DevBench/packages.config

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

+ 3 - 3
QConsole/QConsole/App.config

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

+ 2 - 0
QConsole/QConsole/Command/Base/AbstractCommand.cs

@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using Quadarax.Foundation.Common.Console;
+using Quadarax.Foundation.Common.Value;
 using Quadarax.Foundation.QConsole.Argument;
 using Quadarax.Foundation.QConsole.Extensions;
 

+ 2 - 0
QConsole/QConsole/Command/Base/AbstractListCommand.cs

@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using Quadarax.Foundation.Common.Console;
+using Quadarax.Foundation.Common.Value;
 using Quadarax.Foundation.QConsole.Argument;
 using Quadarax.Foundation.QConsole.Value;
 

+ 2 - 0
QConsole/QConsole/Command/Base/AbstractSelectionCommand.cs

@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using Quadarax.Foundation.Common.Console;
+using Quadarax.Foundation.Common.Value;
 using Quadarax.Foundation.QConsole.Argument;
 
 namespace Quadarax.Foundation.QConsole.Command.Base

+ 3 - 1
QConsole/QConsole/Command/Defaults/CmdClear.cs

@@ -1,4 +1,6 @@
-using Quadarax.Foundation.QConsole.Attributes;
+using Quadarax.Foundation.Common.Console;
+using Quadarax.Foundation.Common.Value;
+using Quadarax.Foundation.QConsole.Attributes;
 using Quadarax.Foundation.QConsole.Command.Base;
 
 namespace Quadarax.Foundation.QConsole.Command.Defaults

+ 2 - 1
QConsole/QConsole/Command/Defaults/CmdExit.cs

@@ -1,4 +1,5 @@
-using Quadarax.Foundation.QConsole.Attributes;
+using Quadarax.Foundation.Common.Value;
+using Quadarax.Foundation.QConsole.Attributes;
 using Quadarax.Foundation.QConsole.Command.Base;
 
 namespace Quadarax.Foundation.QConsole.Command.Defaults

+ 2 - 0
QConsole/QConsole/Command/Defaults/CmdHelp.cs

@@ -2,6 +2,8 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using Quadarax.Foundation.Common.Console;
+using Quadarax.Foundation.Common.Value;
 using Quadarax.Foundation.QConsole.Argument;
 using Quadarax.Foundation.QConsole.Attributes;
 using Quadarax.Foundation.QConsole.Command.Base;

+ 2 - 0
QConsole/QConsole/Command/Defaults/CmdPrint.cs

@@ -2,6 +2,8 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Net.Mime;
+using Quadarax.Foundation.Common.Console;
+using Quadarax.Foundation.Common.Value;
 using Quadarax.Foundation.QConsole.Argument;
 using Quadarax.Foundation.QConsole.Attributes;
 using Quadarax.Foundation.QConsole.Command.Base;

+ 2 - 0
QConsole/QConsole/Command/Defaults/CmdSelection.cs

@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using Quadarax.Foundation.Common.Console;
+using Quadarax.Foundation.Common.Value;
 using Quadarax.Foundation.QConsole.Argument;
 using Quadarax.Foundation.QConsole.Attributes;
 using Quadarax.Foundation.QConsole.Command.Base;

+ 0 - 24
QConsole/QConsole/Command/Result.cs

@@ -1,24 +0,0 @@
-using System;
-
-namespace Quadarax.Foundation.QConsole.Command
-{
-    
-    public class Result
-    {        
-    
-        public bool IsSuccess { get; }
-        public Exception ThrownException { get; }
-
-
-        public Result(Exception e)
-        {
-            ThrownException = e;
-            IsSuccess = false;
-        }
-
-        public Result()
-        {
-            IsSuccess = true;
-        }
-    }
-}

+ 2 - 1
QConsole/QConsole/Configuration/StartupConfiguration.cs

@@ -92,7 +92,7 @@ namespace Quadarax.Foundation.QConsole.Configuration
             set 
             { 
                 _isConsoleDebug = value;
-                ConsoleWriter.IsWriteDebugEnabled = value;
+                DebugConsoleWriter.IsWriteDebugEnabled = value;
             }
         }
         #endregion
@@ -150,6 +150,7 @@ namespace Quadarax.Foundation.QConsole.Configuration
             AllowPreset = Defaults.Console.PresetAllowed;
             IsConsoleDebug = Defaults.Console.ConsoleDebugMode;
             DisableDefaultCommands = Defaults.Console.DisableDefaultCommands;
+            WaitOnKeyInNonInteractiveMode = Defaults.Console.WaitOnKeyInNonInteractiveMode;
 
         }
         #endregion

+ 0 - 79
QConsole/QConsole/ConsoleWriter.cs

@@ -1,79 +0,0 @@
-using System;
-
-
-namespace Quadarax.Foundation.QConsole
-{
-    public class ConsoleWriter : IDisposable
-    {
-        private bool _isDispoising;
-        private ConsoleColor _oldBackColor;
-        private ConsoleColor _oldForeColor;
-        private ConsoleColor _backColor;
-        private ConsoleColor _foreColor;
-
-
-        public static bool IsWriteDebugEnabled { get; set; }
-
-        public ConsoleWriter(ConsoleColor foreColor,ConsoleColor backColor)
-        {
-            _oldBackColor = Console.BackgroundColor;
-            _oldForeColor = Console.ForegroundColor;
-            _backColor = backColor;
-            _foreColor = foreColor;
-        }
-
-        public ConsoleWriter(ConsoleColor foreColor)
-        {
-            _oldBackColor = Console.BackgroundColor;
-            _oldForeColor = Console.ForegroundColor;
-            _backColor = _oldBackColor;
-            _foreColor = foreColor;
-        }
-
-
-        public ConsoleWriter WriteLine(string text)
-        {
-            SetColor();
-            Console.WriteLine(text);
-            return this;
-        }
-
-        public string ReadLine()
-        {
-            SetColor();
-            return Console.ReadLine();
-        }
-
-        public ConsoleWriter WriteLine()
-        {
-            Console.WriteLine();
-            return this;
-        }
-        public ConsoleWriter Write(string text)
-        {
-            SetColor();
-            Console.Write(text);
-            return this;
-        }
-
-        public static void Clear()
-        {
-            Console.Clear();
-        }
-        public void Dispose()
-        {
-            if (_isDispoising)
-                return;
-            _isDispoising = true;
-            Console.ForegroundColor = _oldForeColor;
-            Console.BackgroundColor = _oldBackColor;
-        }
-
-        private void SetColor()
-        {
-            Console.ForegroundColor = _foreColor;
-            Console.BackgroundColor = _backColor;
-        }
-
-    }
-}

+ 3 - 0
QConsole/QConsole/DebugConsoleWriter.cs

@@ -1,10 +1,13 @@
 using System;
+using Quadarax.Foundation.Common.Console;
 
 
 namespace Quadarax.Foundation.QConsole
 {
     public class DebugConsoleWriter : ConsoleWriter
     {
+        public static bool IsWriteDebugEnabled { get; set; }
+
         public DebugConsoleWriter(ConsoleColor backColor) : base(Defaults.Console.ConsoleDebugForeColor, backColor)
         {
         }

+ 1 - 0
QConsole/QConsole/Defaults.cs

@@ -15,6 +15,7 @@ namespace Quadarax.Foundation.QConsole
             internal const bool ConsoleDebugMode = false;
             internal const ConsoleColor ConsoleDebugForeColor = ConsoleColor.DarkGray;
             internal const bool DisableDefaultCommands = false;
+            internal const bool WaitOnKeyInNonInteractiveMode = false;
         }
 
         internal class Formats

+ 11 - 0
QConsole/QConsole/Engine.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Reflection;
+using Quadarax.Foundation.Common.Console;
 using Quadarax.Foundation.QConsole.Attributes;
 using Quadarax.Foundation.QConsole.Command.Base;
 using Quadarax.Foundation.QConsole.Command.Defaults;
@@ -127,6 +128,16 @@ namespace Quadarax.Foundation.QConsole
                         }
                     }
                 }
+
+                if (!Configuration.AllowInteractive && Configuration.WaitOnKeyInNonInteractiveMode)
+                {
+                    WriteDebugInfo("Waiting for the key by configuration settings...");
+                    using (var writerGreen = new ConsoleWriter(ConsoleColor.Magenta))
+                    {
+                        writerGreen.WriteLine("Press any key to close...");
+                        Console.ReadKey();
+                    }
+                }
             }
         }
 

+ 0 - 48
QConsole/QConsole/Extensions/TypePropertyLocator.cs

@@ -1,48 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace Quadarax.Foundation.QConsole.Extensions
-{
-    public static class TypePropertyLocator
-    {
-        private static readonly IDictionary<string, PropertyInfo> _propertyCache = new Dictionary<string, PropertyInfo>();
-
-
-        public static PropertyInfo GetProperty(this Type type, string propertyName)
-        {
-            var key = GetCacheKey(type, propertyName);
-            if (_propertyCache.ContainsKey(key))
-                return _propertyCache[key];
-            var properties = type.GetProperties(BindingFlags.Public | BindingFlags.IgnoreCase);
-            var property = properties.SingleOrDefault(x => x.Name == propertyName);
-            if (property!=null)
-                _propertyCache.Add(key,property);
-            return property;
-        }
-
-        public static object GetPropertyValue(this Type type, string propertyName, object sourceObject)
-        {
-            if (sourceObject==null)
-                throw new ArgumentNullException(nameof(sourceObject));
-            var property = type.GetProperty(propertyName);
-            if (property == null)
-                throw new ArgumentException($"Property '{propertyName}' doesn't exists in type '{type.Name}'.", nameof(propertyName));
-            return property.GetValue(sourceObject);
-        }
-
-        public static string GetPropertyValueAsString(this Type type, string propertyName, object sourceObject)
-        {
-            var value = type.GetPropertyValue(propertyName, sourceObject);
-            return value != null? value.ToString() : string.Empty;
-        }
-
-        private static string GetCacheKey(Type type, string propertyName)
-        {
-            if (string.IsNullOrEmpty(propertyName))
-                throw new ArgumentNullException(nameof(propertyName));
-            return type.FullName + "_" + propertyName;
-        }
-    }
-}

+ 6 - 4
QConsole/QConsole/QDR.FND.QConsole.csproj

@@ -8,10 +8,11 @@
     <OutputType>Library</OutputType>
     <RootNamespace>Quadarax.Foundation.QConsole</RootNamespace>
     <AssemblyName>QDR.FND.QConsole</AssemblyName>
-    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -45,6 +46,9 @@
     <ApplicationIcon>quadarax_dll.ico</ApplicationIcon>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="QDR.FND.Common, Version=1.0.0.5, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\Quadarax.Foundation.Common.1.0.0.5\lib\net472\QDR.FND.Common.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Drawing" />
@@ -70,15 +74,12 @@
     <Compile Include="Command\Defaults\CmdHelp.cs" />
     <Compile Include="Command\Defaults\CmdPrint.cs" />
     <Compile Include="Command\Defaults\CmdSelection.cs" />
-    <Compile Include="Command\Result.cs" />
     <Compile Include="Configuration\StartupConfiguration.cs" />
-    <Compile Include="ConsoleWriter.cs" />
     <Compile Include="Constants.cs" />
     <Compile Include="DebugConsoleWriter.cs" />
     <Compile Include="Defaults.cs" />
     <Compile Include="Engine.cs" />
     <Compile Include="Extensions\AbstractArgumentExt.cs" />
-    <Compile Include="Extensions\TypePropertyLocator.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Value\AbstractValue.cs" />
     <Compile Include="Value\BoolValue.cs" />
@@ -93,6 +94,7 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="App.config" />
+    <None Include="packages.config" />
     <None Include="quadarax_strong_name_key.pfx" />
   </ItemGroup>
   <ItemGroup>

+ 1 - 0
QConsole/QConsole/ReleaseNote.txt

@@ -3,6 +3,7 @@ New
  - Allows to use more asseblies in CommandDefinitionAssebmly
  - Add DisableDefaultCommands to StartupConfiguration to hide default commands
  - Add WaitOnKeyInNonInteractiveMode to wait on key at the end of the non-interactive process
+ - Use reference Quadarax.Foundation.Common
 Fix
  - Flag arguments behaviours
  - NonIteractive usage

+ 4 - 0
QConsole/QConsole/packages.config

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