namespace Unosquare.Swan
{
using Reflection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
///
/// Contains useful constants and definitions.
///
public static partial class Definitions
{
#region Main Dictionary Definition
///
/// The basic types information.
///
public static readonly Dictionary BasicTypesInfo =
new Dictionary
{
// Non-Nullables
{typeof(DateTime), new ExtendedTypeInfo()},
{typeof(byte), new ExtendedTypeInfo()},
{typeof(sbyte), new ExtendedTypeInfo()},
{typeof(int), new ExtendedTypeInfo()},
{typeof(uint), new ExtendedTypeInfo()},
{typeof(short), new ExtendedTypeInfo()},
{typeof(ushort), new ExtendedTypeInfo()},
{typeof(long), new ExtendedTypeInfo()},
{typeof(ulong), new ExtendedTypeInfo()},
{typeof(float), new ExtendedTypeInfo()},
{typeof(double), new ExtendedTypeInfo()},
{typeof(char), new ExtendedTypeInfo()},
{typeof(bool), new ExtendedTypeInfo()},
{typeof(decimal), new ExtendedTypeInfo()},
{typeof(Guid), new ExtendedTypeInfo()},
// Strings is also considered a basic type (it's the only basic reference type)
{typeof(string), new ExtendedTypeInfo()},
// Nullables
{typeof(DateTime?), new ExtendedTypeInfo()},
{typeof(byte?), new ExtendedTypeInfo()},
{typeof(sbyte?), new ExtendedTypeInfo()},
{typeof(int?), new ExtendedTypeInfo()},
{typeof(uint?), new ExtendedTypeInfo()},
{typeof(short?), new ExtendedTypeInfo()},
{typeof(ushort?), new ExtendedTypeInfo()},
{typeof(long?), new ExtendedTypeInfo()},
{typeof(ulong?), new ExtendedTypeInfo()},
{typeof(float?), new ExtendedTypeInfo()},
{typeof(double?), new ExtendedTypeInfo()},
{typeof(char?), new ExtendedTypeInfo()},
{typeof(bool?), new ExtendedTypeInfo()},
{typeof(decimal?), new ExtendedTypeInfo()},
{typeof(Guid?), new ExtendedTypeInfo()},
// Additional Types
{typeof(TimeSpan), new ExtendedTypeInfo()},
{typeof(TimeSpan?), new ExtendedTypeInfo()},
{typeof(IPAddress), new ExtendedTypeInfo()},
};
#endregion
///
/// Contains all basic types, including string, date time, and all of their nullable counterparts.
///
///
/// All basic types.
///
public static List AllBasicTypes { get; } = new List(BasicTypesInfo.Keys.ToArray());
///
/// Gets all numeric types including their nullable counterparts.
/// Note that Booleans and Guids are not considered numeric types.
///
///
/// All numeric types.
///
public static List AllNumericTypes { get; } = new List(
BasicTypesInfo
.Where(kvp => kvp.Value.IsNumeric)
.Select(kvp => kvp.Key).ToArray());
///
/// Gets all numeric types without their nullable counterparts.
/// Note that Booleans and Guids are not considered numeric types.
///
///
/// All numeric value types.
///
public static List AllNumericValueTypes { get; } = new List(
BasicTypesInfo
.Where(kvp => kvp.Value.IsNumeric && kvp.Value.IsNullableValueType == false)
.Select(kvp => kvp.Key).ToArray());
///
/// Contains all basic value types. i.e. excludes string and nullables.
///
///
/// All basic value types.
///
public static List AllBasicValueTypes { get; } = new List(
BasicTypesInfo
.Where(kvp => kvp.Value.IsValueType)
.Select(kvp => kvp.Key).ToArray());
///
/// Contains all basic value types including the string type. i.e. excludes nullables.
///
///
/// All basic value and string types.
///
public static List AllBasicValueAndStringTypes { get; } = new List(
BasicTypesInfo
.Where(kvp => kvp.Value.IsValueType || kvp.Key == typeof(string))
.Select(kvp => kvp.Key).ToArray());
///
/// Gets all nullable value types. i.e. excludes string and all basic value types.
///
///
/// All basic nullable value types.
///
public static List AllBasicNullableValueTypes { get; } = new List(
BasicTypesInfo
.Where(kvp => kvp.Value.IsNullableValueType)
.Select(kvp => kvp.Key).ToArray());
}
}