mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-02 15:50:47 +08:00
1. Workben项目中,优化了Node的入参类型与返回类型包含泛型成员的类型显示。
This commit is contained in:
@@ -342,7 +342,7 @@ namespace Serein.Library
|
||||
}
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($"返回值信息:");
|
||||
sb.AppendLine($"\t{this.ReturnType?.FullName}");
|
||||
sb.AppendLine($"\t{this.ReturnType?.GetFriendlyName()}");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -499,7 +499,7 @@ namespace Serein.Library
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{this.Index}] {(string.IsNullOrWhiteSpace(this.Description) ? string.Empty : $"({this.Description})")}{this.Name} : {this.DataType?.FullName}";
|
||||
return $"[{this.Index}] {(string.IsNullOrWhiteSpace(this.Description) ? string.Empty : $"({this.Description})")}{this.Name} : {this.DataType?.GetFriendlyName()}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Serein.Library
|
||||
/// <returns></returns>
|
||||
public static bool @bool(object value)
|
||||
{
|
||||
return ConvertHelper.ValueParse<bool>(value);
|
||||
return ObjectConvertHelper.ValueParse<bool>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -37,7 +37,7 @@ namespace Serein.Library
|
||||
/// <returns></returns>
|
||||
public static byte @byte(object value)
|
||||
{
|
||||
return ConvertHelper.ValueParse<byte>(value);
|
||||
return ObjectConvertHelper.ValueParse<byte>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -47,7 +47,7 @@ namespace Serein.Library
|
||||
/// <returns></returns>
|
||||
public static decimal @decimal(object value)
|
||||
{
|
||||
return ConvertHelper.ValueParse<decimal>(value);
|
||||
return ObjectConvertHelper.ValueParse<decimal>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,7 +57,7 @@ namespace Serein.Library
|
||||
/// <returns></returns>
|
||||
public static float @float(object value)
|
||||
{
|
||||
return ConvertHelper.ValueParse<float>(value);
|
||||
return ObjectConvertHelper.ValueParse<float>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,7 +67,7 @@ namespace Serein.Library
|
||||
/// <returns></returns>
|
||||
public static double @double(object value)
|
||||
{
|
||||
return ConvertHelper.ValueParse<double>(value);
|
||||
return ObjectConvertHelper.ValueParse<double>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,7 +77,7 @@ namespace Serein.Library
|
||||
/// <returns></returns>
|
||||
public static int @int(object value)
|
||||
{
|
||||
return ConvertHelper.ValueParse<int>(value);
|
||||
return ObjectConvertHelper.ValueParse<int>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -87,7 +87,7 @@ namespace Serein.Library
|
||||
/// <returns></returns>
|
||||
public static int @long(object value)
|
||||
{
|
||||
return ConvertHelper.ValueParse<int>(value);
|
||||
return ObjectConvertHelper.ValueParse<int>(value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,370 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Serein.Library.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// 类型转换工具类
|
||||
/// </summary>
|
||||
public static class ConvertHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 字面量转为对应类型
|
||||
/// </summary>
|
||||
/// <param name="valueStr"></param>
|
||||
/// <returns></returns>
|
||||
public static Type ToTypeOfString(this string valueStr)
|
||||
{
|
||||
if (valueStr.IndexOf('.') != -1)
|
||||
{
|
||||
// 通过指定的类型名称获取类型
|
||||
return Type.GetType(valueStr);
|
||||
}
|
||||
|
||||
|
||||
if (valueStr.Equals("bool", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(bool);
|
||||
}
|
||||
#region 整数型
|
||||
else if (valueStr.Equals("sbyte", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(SByte), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(SByte);
|
||||
}
|
||||
else if (valueStr.Equals("short", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Int16), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Int16);
|
||||
}
|
||||
else if (valueStr.Equals("int", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Int32), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Int32);
|
||||
}
|
||||
else if (valueStr.Equals("long", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Int64), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Int64);
|
||||
}
|
||||
|
||||
else if (valueStr.Equals("byte", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Byte), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Byte);
|
||||
}
|
||||
else if (valueStr.Equals("ushort", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(UInt16), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(UInt16);
|
||||
}
|
||||
else if (valueStr.Equals("uint", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(UInt32), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(UInt32);
|
||||
}
|
||||
else if (valueStr.Equals("ulong", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(UInt64), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(UInt64);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 浮点型
|
||||
else if (valueStr.Equals("float", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Single), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Single);
|
||||
}
|
||||
else if (valueStr.Equals("double", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Double), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Double);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 小数型
|
||||
|
||||
else if (valueStr.Equals("decimal", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Decimal), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Decimal);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 其他常见的类型
|
||||
else if (valueStr.Equals(nameof(DateTime), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(DateTime);
|
||||
}
|
||||
|
||||
else if (valueStr.Equals(nameof(String), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(String);
|
||||
}
|
||||
#endregion
|
||||
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"无法解析的字面量类型[{valueStr}]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对象转换为对应类型
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult"></typeparam>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static TResult ToConvert<TResult>(this object data)
|
||||
{
|
||||
var type = typeof(TResult);
|
||||
if (data is null && type.IsValueType)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
return (TResult)data.ToConvertValueType(type);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对象转换
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public static object ToConvertValueType(this object data, Type type)
|
||||
{
|
||||
if (type.IsValueType)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ConvertHelper.ValueParse(type, data);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 文本
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static T ValueParse<T>(object value) where T : struct, IComparable<T>
|
||||
{
|
||||
if (value is T data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
string valueStr = value.ToString();
|
||||
return valueStr.ToValueData<T>() ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本转换数值
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static object ValueParse(Type type, object value)
|
||||
{
|
||||
string valueStr = value.ToString();
|
||||
return valueStr.ToValueData(type);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本转换值对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="valueStr"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static T ToValueData<T>(this string valueStr) where T : struct, IComparable<T>
|
||||
{
|
||||
if (string.IsNullOrEmpty(valueStr))
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
//return default(T);
|
||||
}
|
||||
var type = typeof(T);
|
||||
object result;
|
||||
if (type.IsEnum)
|
||||
{
|
||||
result = Enum.Parse(type, valueStr);
|
||||
}
|
||||
else if (type == typeof(bool))
|
||||
{
|
||||
result = bool.Parse(valueStr);
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
result = float.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(decimal))
|
||||
{
|
||||
result = decimal.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(double))
|
||||
{
|
||||
result = double.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(sbyte))
|
||||
{
|
||||
result = sbyte.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(byte))
|
||||
{
|
||||
result = byte.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(short))
|
||||
{
|
||||
result = short.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(ushort))
|
||||
{
|
||||
result = ushort.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(int))
|
||||
{
|
||||
result = int.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(uint))
|
||||
{
|
||||
result = uint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(long))
|
||||
{
|
||||
result = long.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(ulong))
|
||||
{
|
||||
result = ulong.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
#if NET6_0 || NET7_0 || NET8_0
|
||||
else if (type == typeof(nint))
|
||||
{
|
||||
result = nint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(nuint))
|
||||
{
|
||||
result = nuint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("非预期值类型");
|
||||
}
|
||||
|
||||
return (T)result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将字符串转换为指定类型的值对象。
|
||||
/// </summary>
|
||||
/// <param name="valueStr"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static object ToValueData(this string valueStr, Type type)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(valueStr))
|
||||
{
|
||||
return Activator.CreateInstance(type);
|
||||
}
|
||||
object result;
|
||||
if (type.IsEnum)
|
||||
{
|
||||
result = Enum.Parse(type, valueStr);
|
||||
}
|
||||
else if (type == typeof(bool))
|
||||
{
|
||||
result = bool.Parse(valueStr);
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
result = float.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(decimal))
|
||||
{
|
||||
result = decimal.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(double))
|
||||
{
|
||||
result = double.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(sbyte))
|
||||
{
|
||||
result = sbyte.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(byte))
|
||||
{
|
||||
result = byte.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(short))
|
||||
{
|
||||
result = short.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(ushort))
|
||||
{
|
||||
result = ushort.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(int))
|
||||
{
|
||||
result = int.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(uint))
|
||||
{
|
||||
result = uint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(long))
|
||||
{
|
||||
result = long.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(ulong))
|
||||
{
|
||||
result = ulong.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
#if NET6_0 || NET7_0 || NET8_0
|
||||
else if (type == typeof(nint))
|
||||
{
|
||||
result = nint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(nuint))
|
||||
{
|
||||
result = nuint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
#endif
|
||||
else if(type == typeof(DateTime))
|
||||
{
|
||||
if (valueStr.Equals("now"))
|
||||
{
|
||||
return DateTime.Now;
|
||||
}
|
||||
else if (valueStr.Equals("utcnow"))
|
||||
{
|
||||
return DateTime.UtcNow;
|
||||
}
|
||||
return DateTime.Parse(valueStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("非预期值类型");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Serein.Library.Utils
|
||||
{
|
||||
@@ -80,5 +82,259 @@ namespace Serein.Library.Utils
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对象转换为对应类型
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult"></typeparam>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static TResult ToConvert<TResult>(this object data)
|
||||
{
|
||||
var type = typeof(TResult);
|
||||
if (data is null && type.IsValueType)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
return (TResult)data.ToConvertValueType(type);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对象转换
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public static object ToConvertValueType(this object data, Type type)
|
||||
{
|
||||
if (type.IsValueType)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ObjectConvertHelper.ValueParse(type, data);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 文本
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static T ValueParse<T>(object value) where T : struct, IComparable<T>
|
||||
{
|
||||
if (value is T data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
string valueStr = value.ToString();
|
||||
return valueStr.ToValueData<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本转换数值
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static object ValueParse(Type type, object value)
|
||||
{
|
||||
string valueStr = value.ToString();
|
||||
return valueStr.ToValueData(type);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本转换值对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="valueStr"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static T ToValueData<T>(this string valueStr) where T : struct, IComparable<T>
|
||||
{
|
||||
if (string.IsNullOrEmpty(valueStr))
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
//return default(T);
|
||||
}
|
||||
var type = typeof(T);
|
||||
object result;
|
||||
if (type.IsEnum)
|
||||
{
|
||||
result = Enum.Parse(type, valueStr);
|
||||
}
|
||||
else if (type == typeof(bool))
|
||||
{
|
||||
result = bool.Parse(valueStr);
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
result = float.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(decimal))
|
||||
{
|
||||
result = decimal.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(double))
|
||||
{
|
||||
result = double.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(sbyte))
|
||||
{
|
||||
result = sbyte.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(byte))
|
||||
{
|
||||
result = byte.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(short))
|
||||
{
|
||||
result = short.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(ushort))
|
||||
{
|
||||
result = ushort.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(int))
|
||||
{
|
||||
result = int.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(uint))
|
||||
{
|
||||
result = uint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(long))
|
||||
{
|
||||
result = long.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(ulong))
|
||||
{
|
||||
result = ulong.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
#if NET6_0 || NET7_0 || NET8_0
|
||||
else if (type == typeof(nint))
|
||||
{
|
||||
result = nint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(nuint))
|
||||
{
|
||||
result = nuint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("非预期值类型");
|
||||
}
|
||||
|
||||
return (T)result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将字符串转换为指定类型的值对象。
|
||||
/// </summary>
|
||||
/// <param name="valueStr"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static object ToValueData(this string valueStr, Type type)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(valueStr))
|
||||
{
|
||||
return Activator.CreateInstance(type);
|
||||
}
|
||||
object result;
|
||||
if (type.IsEnum)
|
||||
{
|
||||
result = Enum.Parse(type, valueStr);
|
||||
}
|
||||
else if (type == typeof(bool))
|
||||
{
|
||||
result = bool.Parse(valueStr);
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
result = float.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(decimal))
|
||||
{
|
||||
result = decimal.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(double))
|
||||
{
|
||||
result = double.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(sbyte))
|
||||
{
|
||||
result = sbyte.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(byte))
|
||||
{
|
||||
result = byte.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(short))
|
||||
{
|
||||
result = short.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(ushort))
|
||||
{
|
||||
result = ushort.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(int))
|
||||
{
|
||||
result = int.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(uint))
|
||||
{
|
||||
result = uint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(long))
|
||||
{
|
||||
result = long.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(ulong))
|
||||
{
|
||||
result = ulong.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
#if NET6_0 || NET7_0 || NET8_0
|
||||
else if (type == typeof(nint))
|
||||
{
|
||||
result = nint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
else if (type == typeof(nuint))
|
||||
{
|
||||
result = nuint.Parse(valueStr, CultureInfo.InvariantCulture);
|
||||
}
|
||||
#endif
|
||||
else if (type == typeof(DateTime))
|
||||
{
|
||||
if (valueStr.Equals("now"))
|
||||
{
|
||||
return DateTime.Now;
|
||||
}
|
||||
else if (valueStr.Equals("utcnow"))
|
||||
{
|
||||
return DateTime.UtcNow;
|
||||
}
|
||||
return DateTime.Parse(valueStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("非预期值类型");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
180
Library/Utils/TypeHelper.cs
Normal file
180
Library/Utils/TypeHelper.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Serein.Library.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// 类型转换工具类
|
||||
/// </summary>
|
||||
public static class TypeHelper
|
||||
{
|
||||
|
||||
|
||||
public static string GetFriendlyName(this Type type,bool isFullName = true)
|
||||
{
|
||||
if (type.IsGenericType)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
string typeName = isFullName? type.FullName : type.Name;
|
||||
int backtickIndex = typeName.IndexOf('`');
|
||||
if (backtickIndex > 0)
|
||||
{
|
||||
typeName = typeName.Substring(0, backtickIndex);
|
||||
}
|
||||
|
||||
builder.Append(typeName);
|
||||
builder.Append('<');
|
||||
|
||||
Type[] genericArgs = type.GetGenericArguments();
|
||||
for (int i = 0; i < genericArgs.Length; i++)
|
||||
{
|
||||
builder.Append(genericArgs[i].GetFriendlyName(isFullName));
|
||||
if (i < genericArgs.Length - 1)
|
||||
builder.Append(", ");
|
||||
}
|
||||
|
||||
builder.Append('>');
|
||||
return builder.ToString();
|
||||
}
|
||||
else if (type.IsArray)
|
||||
{
|
||||
return $"{type.GetElementType().GetFriendlyName()}[]";
|
||||
}
|
||||
else
|
||||
{
|
||||
return TypeMap.TryGetValue(type, out var alias) ? alias : isFullName ? type.FullName : type.Name; ;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Dictionary<Type, string> TypeMap = new Dictionary<Type, string>
|
||||
{
|
||||
[typeof(int)] = "int",
|
||||
[typeof(string)] = "string",
|
||||
[typeof(bool)] = "bool",
|
||||
[typeof(void)] = "void",
|
||||
[typeof(object)] = "object",
|
||||
[typeof(double)] = "double",
|
||||
[typeof(float)] = "float",
|
||||
[typeof(long)] = "long",
|
||||
[typeof(byte)] = "byte",
|
||||
[typeof(char)] = "char",
|
||||
[typeof(decimal)] = "decimal",
|
||||
[typeof(short)] = "short",
|
||||
[typeof(uint)] = "uint",
|
||||
[typeof(ulong)] = "ulong",
|
||||
[typeof(ushort)] = "ushort",
|
||||
[typeof(sbyte)] = "sbyte",
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 字面量转为对应类型
|
||||
/// </summary>
|
||||
/// <param name="valueStr"></param>
|
||||
/// <returns></returns>
|
||||
public static Type ToTypeOfString(this string valueStr)
|
||||
{
|
||||
if (valueStr.IndexOf('.') != -1)
|
||||
{
|
||||
// 通过指定的类型名称获取类型
|
||||
return Type.GetType(valueStr);
|
||||
}
|
||||
|
||||
|
||||
if (valueStr.Equals("bool", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(bool);
|
||||
}
|
||||
#region 整数型
|
||||
else if (valueStr.Equals("sbyte", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(SByte), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(SByte);
|
||||
}
|
||||
else if (valueStr.Equals("short", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Int16), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Int16);
|
||||
}
|
||||
else if (valueStr.Equals("int", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Int32), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Int32);
|
||||
}
|
||||
else if (valueStr.Equals("long", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Int64), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Int64);
|
||||
}
|
||||
|
||||
else if (valueStr.Equals("byte", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Byte), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Byte);
|
||||
}
|
||||
else if (valueStr.Equals("ushort", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(UInt16), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(UInt16);
|
||||
}
|
||||
else if (valueStr.Equals("uint", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(UInt32), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(UInt32);
|
||||
}
|
||||
else if (valueStr.Equals("ulong", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(UInt64), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(UInt64);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 浮点型
|
||||
else if (valueStr.Equals("float", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Single), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Single);
|
||||
}
|
||||
else if (valueStr.Equals("double", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Double), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Double);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 小数型
|
||||
|
||||
else if (valueStr.Equals("decimal", StringComparison.OrdinalIgnoreCase)
|
||||
|| valueStr.Equals(nameof(Decimal), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(Decimal);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 其他常见的类型
|
||||
else if (valueStr.Equals(nameof(DateTime), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(DateTime);
|
||||
}
|
||||
|
||||
else if (valueStr.Equals(nameof(String), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return typeof(String);
|
||||
}
|
||||
#endregion
|
||||
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"无法解析的字面量类型[{valueStr}]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,15 @@ using System.Windows;
|
||||
|
||||
namespace Serein.Workbench.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// 将集合的元素数量转换为可见性。
|
||||
/// </summary>
|
||||
internal class CountToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public bool Inverse { get; set; } = false; // 可选:反转逻辑
|
||||
/// <summary>
|
||||
/// 可选:是否反转逻辑。
|
||||
/// </summary>
|
||||
public bool Inverse { get; set; } = false;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
|
||||
@@ -8,9 +8,12 @@ using System.Windows.Data;
|
||||
|
||||
namespace Serein.Workbench.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// 选择方法详情的转换器
|
||||
/// </summary>
|
||||
internal class MethodDetailsSelectorConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
bool isShareParam = (bool)values[0];
|
||||
var nodeDetails = values[1];
|
||||
|
||||
36
Workbench/Converters/TypeNameDisplaynConverter.cs
Normal file
36
Workbench/Converters/TypeNameDisplaynConverter.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Serein.Library.Utils;
|
||||
using Serein.Workbench.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Serein.Workbench.Converters
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 类型名称显示转换器
|
||||
/// </summary>
|
||||
internal class TypeNameDisplaynConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if(value is Type type)
|
||||
{
|
||||
string typeName = type.GetFriendlyName(false);
|
||||
return typeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
|
||||
namespace Serein.Workbench.Extension
|
||||
{
|
||||
@@ -44,34 +39,4 @@ namespace Serein.Workbench.Extension
|
||||
return new Vector(me.X, me.Y);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向量(Vector)的扩展方法
|
||||
/// </summary>
|
||||
public static class VectorExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算两个向量的点积。
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public static double DotProduct(this Vector a, Vector b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算两个向量的叉积。
|
||||
/// </summary>
|
||||
/// <param name="v"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector NormalizeTo(this Vector v)
|
||||
{
|
||||
var temp = v;
|
||||
temp.Normalize();
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Workbench/Extension/VectorExtension.cs
Normal file
40
Workbench/Extension/VectorExtension.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Serein.Workbench.Extension
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 向量(Vector)的扩展方法
|
||||
/// </summary>
|
||||
public static class VectorExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算两个向量的点积。
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public static double DotProduct(this Vector a, Vector b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算两个向量的叉积。
|
||||
/// </summary>
|
||||
/// <param name="v"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector NormalizeTo(this Vector v)
|
||||
{
|
||||
var temp = v;
|
||||
temp.Normalize();
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
d:DataContext="{d:DesignInstance vm:ActionNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
MaxWidth="500">
|
||||
|
||||
<UserControl.Resources>
|
||||
<!--<BooleanToVisibilityConverter x:Key="BoolToVisConverter" />-->
|
||||
@@ -86,7 +86,7 @@
|
||||
<TextBlock Text="result ->" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderThickness="1">
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType.FullName, Mode=OneTime}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType, Converter={StaticResource TypeNameDisplaynConverter}}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2" BorderThickness="1">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
d:DataContext="{d:DesignInstance vm:ConditionNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
MaxWidth="500">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.Node.ViewModel"
|
||||
d:DataContext="{d:DesignInstance vm:ExpOpNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
MaxWidth="500">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
d:DataContext="{d:DesignInstance vm:FlipflopNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
MaxWidth="500">
|
||||
|
||||
<UserControl.Resources>
|
||||
<vm:TypeToStringConverter x:Key="TypeToStringConverter"/>
|
||||
@@ -70,7 +70,7 @@
|
||||
<TextBlock Text="result ->" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderThickness="1">
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType.FullName, Mode=OneTime}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType, Converter={StaticResource TypeNameDisplaynConverter}}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2" BorderThickness="1">
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300"
|
||||
|
||||
d:DataContext="{d:DesignInstance vm:FlowCallNodeControlViewModel}">
|
||||
|
||||
<UserControl.Resources>
|
||||
|
||||
@@ -38,14 +38,20 @@ namespace Serein.Workbench.Node.View
|
||||
ViewModel = viewModel;
|
||||
viewModel.NodeModel.DisplayName = "[流程接口]";
|
||||
InitializeComponent();
|
||||
ViewModel.UploadMethodDetailsControl = UploadMethodDetailsControl;
|
||||
ViewModel.UploadNode = UploadMethodDetailsControl;
|
||||
|
||||
}
|
||||
|
||||
private void UploadMethodDetailsControl(MethodDetails methodDetails)
|
||||
private void UploadMethodDetailsControl(IFlowNode? flowNode)
|
||||
{
|
||||
//MethodDetailsControl.MethodDetails = methodDetails;
|
||||
|
||||
if(flowNode is null)
|
||||
{
|
||||
this.MaxWidth = 300;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.MaxWidth = 300;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Node.View"
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.Node.ViewModel"
|
||||
d:DataContext="{d:DesignInstance vm:GlobalDataNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.Node.ViewModel"
|
||||
d:DataContext="{d:DesignInstance vm:GlobalDataNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="500">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
</UserControl.Resources>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
d:DataContext="{d:DesignInstance vm:NetScriptNodeControlViewModel}"
|
||||
|
||||
mc:Ignorable="d"
|
||||
MinWidth="50">
|
||||
MaxWidth="500">
|
||||
<Grid Background="#FEFAF4">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
|
||||
d:DataContext="{d:DesignInstance vm:ScriptNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MinWidth="50">
|
||||
MaxWidth="500">
|
||||
|
||||
<Grid Background="#FEFAF4">
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<TextBlock Text="result ->" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderThickness="1">
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType, Converter={StaticResource TypeNameDisplaynConverter}}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2" BorderThickness="1">
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
/// <summary>
|
||||
/// 刷新方法控件
|
||||
/// </summary>
|
||||
public Action<MethodDetails> UploadMethodDetailsControl;
|
||||
public Action<IFlowNode?> UploadNode;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
@@ -105,9 +105,11 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
{
|
||||
if(value is null)
|
||||
{
|
||||
UploadNode?.Invoke(null);
|
||||
FlowCallNode.ResetTargetNode(); // 如果是不选择了,则重置一下
|
||||
return;
|
||||
}
|
||||
UploadNode.Invoke(value);
|
||||
FlowCallNode.SetTargetNode(value.Guid); // 重新设置目标节点
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<!--<IsRoslynComponent>true</IsRoslynComponent>-->
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net462|AnyCPU'">
|
||||
<NoWarn>1701;1702;1573;CS0414</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Node\NodeModel\**" />
|
||||
<Compile Remove="Themes\Condition\**" />
|
||||
@@ -28,6 +32,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Converters\TypeToColorConverter.cs" />
|
||||
<Compile Remove="MainWindow.xaml.cs" />
|
||||
<Compile Remove="MainWindowViewModel.cs" />
|
||||
<Compile Remove="Node\FlipflopRegionControl.xaml.cs" />
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<converter:InvertableBooleanToVisibilityConverter x:Key="InvertedBoolConverter"/>
|
||||
<converter:EnumToBooleanConverter x:Key="EnumToBooleanConverter"/>
|
||||
<converter:TypeNameDisplaynConverter x:Key="TypeNameDisplaynConverter"/>
|
||||
<local:DescriptionOrNameConverter x:Key="DescOrNameConverter"/>
|
||||
|
||||
|
||||
@@ -21,18 +22,26 @@
|
||||
<Setter.Value>
|
||||
<ControlTemplate x:Name="MethodControlTemplate" TargetType="{x:Type local:MethodDetailsControl}">
|
||||
|
||||
|
||||
<!--根据方法入参数量生成相应的控件-->
|
||||
<ItemsControl ItemsSource="{Binding MethodDetails.ParameterDetailss, RelativeSource={RelativeSource TemplatedParent}}" Background="#E3FDFD" >
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<!-- 共享宽度启用 -->
|
||||
<StackPanel Grid.IsSharedSizeScope="True" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="serein:ParameterData">
|
||||
<Grid DataContext="{Binding}" >
|
||||
<Grid DataContext="{Binding}" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="Col1" Width="auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="Col2" Width="auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="Col3" Width="auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="Col4" Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--连接控制器-->
|
||||
<view:ArgJunctionControl x:Name="ArgJunctionControl" Grid.Column="0" ArgIndex="{Binding Index}"
|
||||
@@ -43,7 +52,7 @@
|
||||
<CheckBox Grid.Column="1" IsChecked="{Binding IsExplicitData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="2,0,2,0" VerticalContentAlignment="Center"/>
|
||||
|
||||
<!--参数类型提示-->
|
||||
<TextBlock Grid.Column="2" Text="{Binding DataType}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding DataType, Converter={StaticResource TypeNameDisplaynConverter}}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
|
||||
|
||||
<!--入参参数名称-->
|
||||
@@ -144,6 +153,7 @@
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
|
||||
|
||||
<!--增加可选参数(如果有)-->
|
||||
<view:ParamsArgControl x:Name="ParamsArgControl"
|
||||
ArgIndex="{Binding Index}"
|
||||
|
||||
Reference in New Issue
Block a user