3 Commits
Author SHA1 Message Date
BlubbFish baed3c9e08 Add GetEvent so you can call events by string
Add OwnSingeton class
2021-04-10 01:18:21 +02:00
BlubbFish edb3069bb0 Make netcore as default, also using 3.1 now 2021-01-08 23:50:43 +01:00
BlubbFish a5249f8fac Update CmdArgs to have more flexibility 2020-05-22 13:20:47 +02:00
9 changed files with 275 additions and 239 deletions
+5 -8
View File
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179 VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "Utils\Utils_Core.csproj", "{A289C67C-BC49-46A0-8657-B444C605079E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "Utils\Utils-4.7.1.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,15 +11,12 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A289C67C-BC49-46A0-8657-B444C605079E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A289C67C-BC49-46A0-8657-B444C605079E}.Debug|Any CPU.Build.0 = Debug|Any CPU {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A289C67C-BC49-46A0-8657-B444C605079E}.Release|Any CPU.ActiveCfg = Release|Any CPU {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A289C67C-BC49-46A0-8657-B444C605079E}.Release|Any CPU.Build.0 = Release|Any CPU {FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A7224DC4-69F1-4273-BE78-3D9DC80A28C5}
EndGlobalSection
EndGlobal EndGlobal
+8 -5
View File
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179 VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "Utils\Utils.csproj", "{A289C67C-BC49-46A0-8657-B444C605079E}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,12 +11,15 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A289C67C-BC49-46A0-8657-B444C605079E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU {A289C67C-BC49-46A0-8657-B444C605079E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU {A289C67C-BC49-46A0-8657-B444C605079E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU {A289C67C-BC49-46A0-8657-B444C605079E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A7224DC4-69F1-4273-BE78-3D9DC80A28C5}
EndGlobalSection
EndGlobal EndGlobal
+21 -4
View File
@@ -14,19 +14,25 @@ namespace BlubbFish.Utils
#region Classes #region Classes
public struct VaildArguments public struct VaildArguments
{ {
public VaildArguments(ArgLength length, Boolean required) public VaildArguments(ArgLength length, Boolean required, String @default = "", String description = "")
{ {
this.Required = required; this.Required = required;
this.Length = length; this.Length = length;
this.Description = description;
this.@Default = @default;
} }
public VaildArguments(ArgLength length) public VaildArguments(ArgLength length, String @default = "", String description = "")
{ {
this.Required = false; this.Required = false;
this.Length = length; this.Length = length;
this.Description = description;
this.@Default = @default;
} }
public ArgLength Length { get; private set; } public ArgLength Length { get; private set; }
public Boolean Required { get; private set; } public Boolean Required { get; private set; }
public String Description { get; private set; }
public String Default { get; private set; }
} }
private struct ArgTouple private struct ArgTouple
{ {
@@ -107,6 +113,11 @@ namespace BlubbFish.Utils
this.argList.Add(arg); this.argList.Add(arg);
} }
} }
foreach(KeyValuePair<String, VaildArguments> item in this.argsPosible) {
if(!this.HasArgumentType(item.Key) && item.Value.Length == ArgLength.Touple && item.Value.Default != "") {
this.argList.Add(new ArgTouple(item.Key, item.Value.Default));
}
}
} }
/// <summary> /// <summary>
@@ -162,7 +173,10 @@ namespace BlubbFish.Utils
String opt = ""; String opt = "";
foreach (KeyValuePair<String, VaildArguments> item in this.argsPosible) { foreach (KeyValuePair<String, VaildArguments> item in this.argsPosible) {
if (item.Value.Required) { if (item.Value.Required) {
req += item.Key + " " + ((item.Value.Length == ArgLength.Touple) ? " [data]\n" : "\n"); req += item.Key + " " + ((item.Value.Length == ArgLength.Touple) ? (item.Value.Default != "" ? " " + item.Value.Default + "\n" : " [data]\n") : "\n");
if(item.Value.Description != "") {
req += "\t" + item.Value.Description + "\n";
}
} }
} }
if (req != "") { if (req != "") {
@@ -170,7 +184,10 @@ namespace BlubbFish.Utils
} }
foreach (KeyValuePair<String, VaildArguments> item in this.argsPosible) { foreach (KeyValuePair<String, VaildArguments> item in this.argsPosible) {
if (!item.Value.Required) { if (!item.Value.Required) {
opt += item.Key + " " + ((item.Value.Length == ArgLength.Touple) ? " [data]\n" : "\n"); opt += item.Key + " " + ((item.Value.Length == ArgLength.Touple) ? (item.Value.Default != "" ? " " + item.Value.Default + "\n" : " [data]\n") : "\n");
if (item.Value.Description != "") {
opt += "\t" + item.Value.Description + "\n";
}
} }
} }
if (opt != "") { if (opt != "") {
+5 -1
View File
@@ -53,6 +53,10 @@ namespace BlubbFish.Utils {
FieldInfo field = o.GetField(name); FieldInfo field = o.GetField(name);
return field.IsPublic ? field.GetValue(o) : null; return field.IsPublic ? field.GetValue(o) : null;
} }
public static T GetEvent<T>(this Object o, String name) {
FieldInfo field = o.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
return (T)field?.GetValue(o);
}
#endregion #endregion
#region InterfaceHelper #region InterfaceHelper
@@ -75,7 +79,7 @@ namespace BlubbFish.Utils {
return attributes != null && attributes.Length > 0 ? attributes[0].Description : value.ToString(); return attributes != null && attributes.Length > 0 ? attributes[0].Description : value.ToString();
} }
public static String ToUpperLower(this String s) => s.Length == 0 ? "" : s.Length == 1 ? s.ToUpper() : s[0].ToString().ToUpper() + s.Substring(1).ToLower(); public static String ToUpperLower(this String s) => s.Length == 0 ? "" : s.Length == 1 ? s.ToUpper() : s[0].ToString().ToUpper() + s[1..].ToLower();
public static void WriteError(String text) { public static void WriteError(String text) {
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
+11
View File
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BlubbFish.Utils {
public abstract class OwnSingeton<T> where T : class {
private static readonly Lazy<T> _instance = new Lazy<T>(() => CreateInstanceOfT());
public static T Instance => _instance.Value;
private static T CreateInstanceOfT() => Activator.CreateInstance(typeof(T), true) as T;
}
}
+4 -3
View File
@@ -11,7 +11,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BlubbFish")] [assembly: AssemblyCompany("BlubbFish")]
[assembly: AssemblyProduct("Utils")] [assembly: AssemblyProduct("Utils")]
[assembly: AssemblyCopyright("Copyright © BlubbFish 2014 - 02.10.2018")] [assembly: AssemblyCopyright("Copyright © BlubbFish 2014 - 10.04.2021")]
[assembly: AssemblyTrademark("BlubbFish")] [assembly: AssemblyTrademark("BlubbFish")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("de-DE")] [assembly: NeutralResourcesLanguage("de-DE")]
@@ -35,10 +35,11 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.0")] [assembly: AssemblyVersion("1.5.0")]
[assembly: AssemblyFileVersion("1.4.0")] [assembly: AssemblyFileVersion("1.5.0")]
#endif #endif
/** /**
* 1.5.0 Add GetEvent so you can call events by string; Add OwnSingeton class
* 1.4.0 Add Helper to Utils * 1.4.0 Add Helper to Utils
*/ */
+72
View File
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BlubbFish.Utils</RootNamespace>
<AssemblyName>Utils</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CmdArgs.cs" />
<Compile Include="EventArgsHelper.cs" />
<Compile Include="FileLogger.cs" />
<Compile Include="FileMutex.cs" />
<Compile Include="Helper.cs" />
<Compile Include="InIReader.cs" />
<Compile Include="OwnController.cs" />
<Compile Include="OwnModel.cs" />
<Compile Include="OwnObject.cs" />
<Compile Include="OwnView.cs" />
<Compile Include="ProgramLogger.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Updater.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\CHANGELOG.md" />
<Content Include="..\CONTRIBUTING.md" />
<Content Include="..\LICENSE" />
<Content Include="..\README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+31 -64
View File
@@ -1,72 +1,39 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <TargetFramework>netcoreapp3.1</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BlubbFish.Utils</RootNamespace>
<AssemblyName>Utils</AssemblyName> <AssemblyName>Utils</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> <RootNamespace>BlubbFish.Utils</RootNamespace>
<FileAlignment>512</FileAlignment> <Description>Provides useful classes for other projects</Description>
<TargetFrameworkProfile /> <Company>BlubbFish</Company>
</PropertyGroup> <Authors>BlubbFish</Authors>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PackageId>Utils.BlubbFish</PackageId>
<DebugSymbols>true</DebugSymbols> <Copyright>Copyright © BlubbFish 2014 - 10.04.2021</Copyright>
<DebugType>full</DebugType> <AssemblyVersion>1.5.0</AssemblyVersion>
<Optimize>false</Optimize> <FileVersion>1.5.0</FileVersion>
<OutputPath>bin\Debug\</OutputPath> <NeutralLanguage>de-DE</NeutralLanguage>
<DefineConstants>DEBUG;TRACE</DefineConstants> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<ErrorReport>prompt</ErrorReport> <PackageProjectUrl>http://git.blubbfish.net/vs_utils/Utils</PackageProjectUrl>
<WarningLevel>4</WarningLevel> <RepositoryUrl>http://git.blubbfish.net/vs_utils/Utils.git</RepositoryUrl>
</PropertyGroup> <RepositoryType>git</RepositoryType>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <Version>1.5.0</Version>
<DebugType>pdbonly</DebugType> <PackageReleaseNotes>
<Optimize>true</Optimize> 1.5.0 Add GetEvent so you can call events by string; Add OwnSingeton class
<OutputPath>bin\Release\</OutputPath> 1.4.0 Add Helper to Utils
<DefineConstants>TRACE</DefineConstants> </PackageReleaseNotes>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Content Include="../CHANGELOG.md" />
<Reference Include="System.Core" /> <Content Include="../CONTRIBUTING.md" />
<Reference Include="System.Windows.Forms" /> <Content Include="../LICENSE" />
<Reference Include="System.Xml.Linq" /> <Content Include="../README.md" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CmdArgs.cs" /> <None Include="..\LICENSE">
<Compile Include="EventArgsHelper.cs" /> <Pack>True</Pack>
<Compile Include="FileLogger.cs" /> <PackagePath></PackagePath>
<Compile Include="FileMutex.cs" /> </None>
<Compile Include="Helper.cs" />
<Compile Include="InIReader.cs" />
<Compile Include="OwnController.cs" />
<Compile Include="OwnModel.cs" />
<Compile Include="OwnObject.cs" />
<Compile Include="OwnView.cs" />
<Compile Include="ProgramLogger.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Updater.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="..\CHANGELOG.md" />
<Content Include="..\CONTRIBUTING.md" />
<Content Include="..\LICENSE" />
<Content Include="..\README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project> </Project>
-36
View File
@@ -1,36 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Utils</AssemblyName>
<RootNamespace>BlubbFish.Utils</RootNamespace>
<Description>Provides useful classes for other projects</Description>
<Company>BlubbFish</Company>
<Authors>BlubbFish</Authors>
<PackageId>Utils.BlubbFish</PackageId>
<Copyright>Copyright © BlubbFish 2014 - 02.10.2018</Copyright>
<AssemblyVersion>1.4.0</AssemblyVersion>
<FileVersion>1.4.0</FileVersion>
<NeutralLanguage>de-DE</NeutralLanguage>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>http://git.blubbfish.net/vs_utils/Utils</PackageProjectUrl>
<RepositoryUrl>http://git.blubbfish.net/vs_utils/Utils.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>1.4.0</Version>
<PackageReleaseNotes>1.4.0 Add Helper to Utils</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<Content Include="../CHANGELOG.md" />
<Content Include="../CONTRIBUTING.md" />
<Content Include="../LICENSE" />
<Content Include="../README.md" />
</ItemGroup>
<ItemGroup>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>