Add GetEvent so you can call events by string
Add OwnSingeton class
This commit is contained in:
parent
edb3069bb0
commit
baed3c9e08
@ -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
Utils/OwnSingeton.cs
Normal file
11
Utils/OwnSingeton.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
@ -8,16 +8,19 @@
|
|||||||
<Company>BlubbFish</Company>
|
<Company>BlubbFish</Company>
|
||||||
<Authors>BlubbFish</Authors>
|
<Authors>BlubbFish</Authors>
|
||||||
<PackageId>Utils.BlubbFish</PackageId>
|
<PackageId>Utils.BlubbFish</PackageId>
|
||||||
<Copyright>Copyright © BlubbFish 2014 - 02.10.2018</Copyright>
|
<Copyright>Copyright © BlubbFish 2014 - 10.04.2021</Copyright>
|
||||||
<AssemblyVersion>1.4.0</AssemblyVersion>
|
<AssemblyVersion>1.5.0</AssemblyVersion>
|
||||||
<FileVersion>1.4.0</FileVersion>
|
<FileVersion>1.5.0</FileVersion>
|
||||||
<NeutralLanguage>de-DE</NeutralLanguage>
|
<NeutralLanguage>de-DE</NeutralLanguage>
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
<PackageProjectUrl>http://git.blubbfish.net/vs_utils/Utils</PackageProjectUrl>
|
<PackageProjectUrl>http://git.blubbfish.net/vs_utils/Utils</PackageProjectUrl>
|
||||||
<RepositoryUrl>http://git.blubbfish.net/vs_utils/Utils.git</RepositoryUrl>
|
<RepositoryUrl>http://git.blubbfish.net/vs_utils/Utils.git</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<Version>1.4.0</Version>
|
<Version>1.5.0</Version>
|
||||||
<PackageReleaseNotes>1.4.0 Add Helper to Utils</PackageReleaseNotes>
|
<PackageReleaseNotes>
|
||||||
|
1.5.0 Add GetEvent so you can call events by string; Add OwnSingeton class
|
||||||
|
1.4.0 Add Helper to Utils
|
||||||
|
</PackageReleaseNotes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user