去除引用common.props
This commit is contained in:
@@ -8,17 +8,17 @@ namespace Tnb.Common.Utils
|
||||
{
|
||||
return objectType == typeof(DateTime);
|
||||
}
|
||||
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
TypeCode typeCode = Type.GetTypeCode(reader.Value.GetType());
|
||||
if (typeCode == TypeCode.DateTime)
|
||||
return reader.Value;
|
||||
|
||||
|
||||
var t = long.Parse((string)(reader.Value.ToString()));
|
||||
return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(t);
|
||||
}
|
||||
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.Common.Utils
|
||||
{
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
|
||||
namespace Tnb.Common.Utils
|
||||
namespace Tnb.Common.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// 迪杰斯特拉(最短路径算法)
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Security.Policy;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Logging;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Newtonsoft.Json;
|
||||
@@ -130,7 +122,7 @@ namespace Tnb.Common.Utils
|
||||
}
|
||||
|
||||
|
||||
public static async Task<string> PostStreamAsync(string url,object content, CancellationToken cancellationToken)
|
||||
public static async Task<string> PostStreamAsync(string url, object content, CancellationToken cancellationToken)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.Common.Utils
|
||||
namespace Tnb.Common.Utils
|
||||
{
|
||||
public class PropertyNotNullChecker<T>
|
||||
{
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.Common.Utils
|
||||
namespace Tnb.Common.Utils
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class SkipNormalizationAttribute : Attribute
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.SpecificationDocument;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Tnb.Common.Utils
|
||||
namespace Tnb.Common.Utils
|
||||
{
|
||||
//public class SkipNormalizationAttributeConventionalRegistrar : IConventionalRegistrar
|
||||
//{
|
||||
|
||||
@@ -5,133 +5,133 @@ namespace System;
|
||||
|
||||
public static class ThrowIf
|
||||
{
|
||||
public static void When(bool isMatch, string msg)
|
||||
{
|
||||
if (isMatch)
|
||||
public static void When(bool isMatch, string msg)
|
||||
{
|
||||
throw new ArgumentException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static T IsNull<T>([NotNull] T? value, string? msg = null, [CallerArgumentExpression("value")] string? paraName = null)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw string.IsNullOrEmpty(msg) ? new ArgumentNullException(paraName) : new ArgumentException(msg);
|
||||
if (isMatch)
|
||||
{
|
||||
throw new ArgumentException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static T IsNullOrDefault<T>([NotNull] T? value, string? msg = null, [CallerArgumentExpression("value")] string? paraName = null) where T : struct
|
||||
{
|
||||
if (!value.HasValue || value.Value.Equals(default(T)))
|
||||
public static T IsNull<T>([NotNull] T? value, string? msg = null, [CallerArgumentExpression("value")] string? paraName = null)
|
||||
{
|
||||
throw string.IsNullOrEmpty(msg) ? new ArgumentException("值不可为空或默认值", paraName) : new ArgumentException(msg);
|
||||
if (value == null)
|
||||
{
|
||||
throw string.IsNullOrEmpty(msg) ? new ArgumentNullException(paraName) : new ArgumentException(msg);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
return value.Value;
|
||||
}
|
||||
|
||||
|
||||
public static string IsNullOrWhiteSpace([NotNull] string? value, string? msg = null, [CallerArgumentExpression("value")] string? paraName = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
public static T IsNullOrDefault<T>([NotNull] T? value, string? msg = null, [CallerArgumentExpression("value")] string? paraName = null) where T : struct
|
||||
{
|
||||
throw string.IsNullOrEmpty(msg) ? new ArgumentException("值不可为空或空格", paraName) : new ArgumentException(msg);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if (!value.HasValue || value.Value.Equals(default(T)))
|
||||
{
|
||||
throw string.IsNullOrEmpty(msg) ? new ArgumentException("值不可为空或默认值", paraName) : new ArgumentException(msg);
|
||||
}
|
||||
|
||||
public static string IsNullOrEmpty([NotNull] string? value, string? msg = null, [CallerArgumentExpression("value")] string? paraName = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw string.IsNullOrEmpty(msg) ? new ArgumentException("值不可为空", paraName) : new ArgumentException(msg);
|
||||
return value.Value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
//public static ICollection<T> NotNullOrEmpty<T>(ICollection<T> value, string paraName)
|
||||
//{
|
||||
// if (value.IsNullOrEmpty())
|
||||
// {
|
||||
// throw new ArgumentException(paraName + " can not be null or empty!", paraName);
|
||||
// }
|
||||
|
||||
// return value;
|
||||
//}
|
||||
|
||||
//public static Type AssignableTo<TBaseType>(Type type, string paraName)
|
||||
//{
|
||||
// NotNull(type, paraName);
|
||||
// if (!type.IsAssignableTo<TBaseType>())
|
||||
// {
|
||||
// throw new ArgumentException(paraName + " (type of " + type.AssemblyQualifiedName + ") should be assignable to the " + typeof(TBaseType).GetFullNameWithAssemblyName() + "!");
|
||||
// }
|
||||
|
||||
// return type;
|
||||
//}
|
||||
|
||||
public static short OutOfRange(short value, string paraName, short minimumValue, short maximumValue = short.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
public static string IsNullOrWhiteSpace([NotNull] string? value, string? msg = null, [CallerArgumentExpression("value")] string? paraName = null)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw string.IsNullOrEmpty(msg) ? new ArgumentException("值不可为空或空格", paraName) : new ArgumentException(msg);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static int OutOfRange(int value, string paraName, int minimumValue, int maximumValue = int.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
public static string IsNullOrEmpty([NotNull] string? value, string? msg = null, [CallerArgumentExpression("value")] string? paraName = null)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw string.IsNullOrEmpty(msg) ? new ArgumentException("值不可为空", paraName) : new ArgumentException(msg);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
//public static ICollection<T> NotNullOrEmpty<T>(ICollection<T> value, string paraName)
|
||||
//{
|
||||
// if (value.IsNullOrEmpty())
|
||||
// {
|
||||
// throw new ArgumentException(paraName + " can not be null or empty!", paraName);
|
||||
// }
|
||||
|
||||
public static long OutOfRange(long value, string paraName, long minimumValue, long maximumValue = long.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
// return value;
|
||||
//}
|
||||
|
||||
//public static Type AssignableTo<TBaseType>(Type type, string paraName)
|
||||
//{
|
||||
// NotNull(type, paraName);
|
||||
// if (!type.IsAssignableTo<TBaseType>())
|
||||
// {
|
||||
// throw new ArgumentException(paraName + " (type of " + type.AssemblyQualifiedName + ") should be assignable to the " + typeof(TBaseType).GetFullNameWithAssemblyName() + "!");
|
||||
// }
|
||||
|
||||
// return type;
|
||||
//}
|
||||
|
||||
public static short OutOfRange(short value, string paraName, short minimumValue, short maximumValue = short.MaxValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float OutOfRange(float value, string paraName, float minimumValue, float maximumValue = float.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
public static int OutOfRange(int value, string paraName, int minimumValue, int maximumValue = int.MaxValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static double OutOfRange(double value, string paraName, double minimumValue, double maximumValue = double.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
public static long OutOfRange(long value, string paraName, long minimumValue, long maximumValue = long.MaxValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static decimal OutOfRange(decimal value, string paraName, decimal minimumValue, decimal maximumValue = decimal.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
public static float OutOfRange(float value, string paraName, float minimumValue, float maximumValue = float.MaxValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
public static double OutOfRange(double value, string paraName, double minimumValue, double maximumValue = double.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static decimal OutOfRange(decimal value, string paraName, decimal minimumValue, decimal maximumValue = decimal.MaxValue)
|
||||
{
|
||||
if (value < minimumValue || value > maximumValue)
|
||||
{
|
||||
throw new ArgumentException($"{paraName} is out of range min: {minimumValue} - max: {maximumValue}");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user