1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using Ant.DbExpressions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Ant.SqlServer
- {
- internal static class Utils
- {
- public static void CheckNull(object obj, string paramName = null)
- {
- if (obj == null)
- throw new ArgumentNullException(paramName);
- }
- public static bool IsNullable(Type type)
- {
- Type unType;
- return IsNullable(type, out unType);
- }
- public static bool IsNullable(Type type, out Type unType)
- {
- unType = Nullable.GetUnderlyingType(type);
- return unType != null;
- }
- public static Type GetUnderlyingType(Type type)
- {
- Type unType;
- if (!IsNullable(type, out unType))
- unType = type;
- return unType;
- }
- public static bool AreEqual(object obj1, object obj2)
- {
- if (obj1 == null && obj2 == null)
- return true;
- if (obj1 != null)
- {
- return obj1.Equals(obj2);
- }
- if (obj2 != null)
- {
- return obj2.Equals(obj1);
- }
- return object.Equals(obj1, obj2);
- }
- public static Dictionary<TKey, TValue> Clone<TKey, TValue>(Dictionary<TKey, TValue> source, IEqualityComparer<TKey> comparer = null)
- {
- Dictionary<TKey, TValue> ret;
- if (comparer == null)
- ret = new Dictionary<TKey, TValue>(source.Count);
- else
- ret = new Dictionary<TKey, TValue>(source.Count, comparer);
- foreach (var kv in source)
- {
- ret.Add(kv.Key, kv.Value);
- }
- return ret;
- }
- }
- }
|