support for .NET framework 3.5
Still have bugs
This commit is contained in:
1 parent
5878039e21
commit
7d6b491f25
704 files changed
+48273
-33
No files matched your search
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControlDemo.Tools
|
||||
{
|
||||
public class AssemblyHelper
|
||||
{
|
||||
private static readonly string NameSpaceStr = typeof(AssemblyHelper).Assembly.GetName().Name;
|
||||
|
||||
public static object CreateInternalInstance(string className)
|
||||
{
|
||||
try
|
||||
{
|
||||
var type = Type.GetType($"{NameSpaceStr}.{className}");
|
||||
return type == null ? null : Activator.CreateInstance(type);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using HandyControl.Data;
|
||||
|
||||
namespace HandyControlDemo.Tools
|
||||
{
|
||||
public class CommonHelper
|
||||
{
|
||||
public static SystemVersionInfo GetSystemVersionInfo()
|
||||
{
|
||||
var managementClass = new ManagementClass("Win32_OperatingSystem");
|
||||
var instances = managementClass.GetInstances();
|
||||
foreach (var instance in instances)
|
||||
{
|
||||
if (instance["Version"] is string version)
|
||||
{
|
||||
var nums = version.Split('.').Select(int.Parse).ToList();
|
||||
var info = new SystemVersionInfo(nums[0], nums[1], nums[2]);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return default(SystemVersionInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControlDemo.Tools.Converter
|
||||
{
|
||||
public class StringRepeatConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string strValue)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
int num;
|
||||
if (parameter is string numStr)
|
||||
{
|
||||
if (!int.TryParse(numStr, out num))
|
||||
{
|
||||
return strValue;
|
||||
}
|
||||
}
|
||||
else if(parameter is int intValue)
|
||||
{
|
||||
num = intValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return strValue;
|
||||
}
|
||||
for (var i = 0; i < num; i++)
|
||||
{
|
||||
builder.Append(strValue);
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user