コード例 #1
0
 public static Boolean IsNullable(this Type baseType)
 {
     return(DDRIT.IsNullable(baseType));
 }
コード例 #2
0
 public static String GetRelativePath(this FileSystemInfo sourcePath, FileSystemInfo destinationPath)
 {
     return(DDRIT.GetRelativePath(sourcePath, destinationPath));
 }
コード例 #3
0
 /// <summary>
 /// Attempt to serialize any object into a Binary Encoded string.
 /// </summary>
 /// <param name="input">The object to serialize.</param>
 /// <returns>A string containing the serialized object.</returns>
 public static String ToBinary(this Object input)
 {
     return(DDRIT.ToBinary(input));
 }
コード例 #4
0
 /// <summary>
 /// Returns the date of the first day of the week starting on <paramref name="startOfWeek" />, which contains <paramref name="date"/>.
 /// </summary>
 /// <param name="date"></param>
 /// <param name="startOfWeek"></param>
 /// <returns></returns>
 public static DateTimeOffset StartOfWeek(this DateTimeOffset date, DayOfWeek startOfWeek = DayOfWeek.Sunday)
 {
     return(DDRIT.StartOfWeek(date, startOfWeek));
 }
コード例 #5
0
 public static TValue GetValue <TKey, TValue>(this Dictionary <TKey, TValue> input, TKey key, TValue @default)
 {
     return(DDRIT.GetValue <TKey, TValue>(input, key, @default));
 }
コード例 #6
0
 /// <summary>
 /// Attempt to serialize any object into a JSON string.
 /// </summary>
 /// <param name="input">The object to serialize.</param>
 /// <returns>A string containing the serialized object.</returns>
 public static String ToJSON(this Object input, Formatting formatting = Formatting.Indented, TypeNameHandling typeNameHandling = TypeNameHandling.None)
 {
     return(DDRIT.ToJSON(input, formatting, typeNameHandling));
 }
コード例 #7
0
 /// <summary>
 /// Trim a DateTime to the smallest whole TimeSpan that fits within a 24 hour period.
 /// </summary>
 /// <param name="input">The time to trim</param>
 /// <param name="interval">The smallest timespan per day to allow</param>
 /// <returns></returns>
 public static DateTimeOffset TrimTo(this DateTimeOffset input, TimeSpan interval)
 {
     return(DDRIT.TrimTo(input, interval));
 }
コード例 #8
0
 /// <summary>
 /// Return the hash of a string value
 /// </summary>
 /// <param name="input">The string to hash</param>
 /// <returns>An SHA512 hash of the given string</returns>
 public static String ToSHA512(this String input)
 {
     return(DDRIT.ToSHA512(input));
 }
コード例 #9
0
 public static TEnum[] ToFlagsArray <TEnum>(this Enum value) where TEnum : struct
 {
     return(DDRIT.ToFlagsArray <TEnum>(value));
 }
コード例 #10
0
 /// <summary>
 /// Converts a the input <paramref name="bytes"/> to a hex string.
 /// </summary>
 /// <param name="bytes">Array of bytes to convert to hex string.</param>
 /// <returns>A hex string representation of the input <paramref name="bytes"/>.</returns>
 public static String ToHex(this Byte[] bytes)
 {
     return(DDRIT.ToHex(bytes));
 }
コード例 #11
0
 /// <summary>
 /// Return the hash of a string value
 /// </summary>
 /// <param name="input">The string to hash</param>
 /// <returns>An MD5 hash of the given string</returns>
 public static String ToMD5(this String input)
 {
     return(DDRIT.ToMD5(input));
 }
コード例 #12
0
 public static String GetFriendlyTypeName(this Type type)
 {
     return(DDRIT.GetFriendlyTypeName(type));
 }
コード例 #13
0
 /// <summary>
 /// Get a list of all non-system dependencies for a given type.
 /// </summary>
 /// <param name="type">The type to interrogate</param>
 /// <returns>An enumerable of all the dependencies referenced by the specified type.</returns>
 public static IEnumerable <Type> GetDependencies(this Type type)
 {
     return(DDRIT.GetDependencies(type));
 }
コード例 #14
0
 public static TAttribute GetAttribute <TAttribute>(this Type type) where TAttribute : Attribute
 {
     return(DDRIT.GetAttribute <TAttribute>(type));
 }
コード例 #15
0
 /// <summary>
 /// Strip HTML/XML tags from any string.
 /// </summary>
 /// <param name="input">HTML content.</param>
 /// <returns>Content free of HTML tags.</returns>
 public static String StripTags(this String input)
 {
     return(DDRIT.StripTags(input));
 }
コード例 #16
0
 public static TEnum FromFlagsArray <TEnum>(this IEnumerable <TEnum> flags) where TEnum : struct
 {
     return(DDRIT.FromFlagsArray <TEnum>(flags));
 }
コード例 #17
0
 /// <summary>
 /// Attempt to deserialize any JSON string into an object.
 /// </summary>
 /// <typeparam name="TResult">The type to convert to.</typeparam>
 /// <param name="input">The string to deserialize to an object.</param>
 /// <returns>An Object of type T deserialized from the string.</returns>
 public static TResult FromJSON <TResult>(this String input, TypeNameHandling typeNameHandling = TypeNameHandling.None)
 {
     return(DDRIT.FromJSON <TResult>(input, typeNameHandling));
 }
コード例 #18
0
 /// <summary>
 /// Return the friendly description of an enum value, if it has been decorated with the DescriptionAttribute,
 /// otherwise, return the internal string representation of the enum value.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static String ToDescription(this Enum value, Boolean expandFlags = true)
 {
     return(DDRIT.ToDescription(value, expandFlags));
 }
コード例 #19
0
 /// <summary>
 /// Attempt to deserialize any JSON string into an object.
 /// </summary>
 /// <param name="input">The string to deserialize to an object.</param>
 /// <param name="type">The type to convert to.</param>
 /// <returns>An Object deserialized from the string.</returns>
 public static Object FromJSON(this String input, Type type, TypeNameHandling typeNameHandling = TypeNameHandling.None)
 {
     return(DDRIT.FromJSON(input, type, typeNameHandling));
 }
コード例 #20
0
 public static TEnum?ToEnum <TEnum>(this Enum value, TEnum? @default) where TEnum : struct
 {
     return(DDRIT.ToEnum <TEnum>(value, @default));
 }
コード例 #21
0
 /// <summary>
 /// Trim a TimeSpan to the smallest whole TimeSpan that fits within a 24 hour period.
 /// </summary>
 /// <param name="input">The time to trim</param>
 /// <param name="interval">The smallest timespan per day to allow</param>
 /// <returns></returns>
 public static TimeSpan TrimTo(this TimeSpan input, TimeSpan interval)
 {
     return(DDRIT.TrimTo(input, interval));
 }
コード例 #22
0
 public static TEnum?ToEnum <TEnum>(this String input, Boolean ignoreCase = true) where TEnum : struct
 {
     return(DDRIT.ToEnum <TEnum>(input, ignoreCase));
 }
コード例 #23
0
 /// <summary>
 /// Returns the date of the last day of the week ending on <paramref name="startOfWeek"/>, which contains <paramref name="date"/>.
 /// </summary>
 /// <param name="date"></param>
 /// <param name="startOfWeek"></param>
 /// <returns></returns>
 public static DateTime EndOfWeek(this DateTime date, DayOfWeek startOfWeek = DayOfWeek.Sunday)
 {
     return(DDRIT.EndOfWeek(date, startOfWeek));
 }
コード例 #24
0
 /// <typeparam name="TSource"></typeparam>
 /// <param name="source">The System.Collections.Generic.IEnumerable&lt;<typeparamref name="TSource"/>&gt; to return the first element of.</param>
 /// <param name="default">The default value to return if the source is empty.</param>
 /// <returns><paramref name="default"/> if <paramref name="source"/> is empty; otherwise, the first element in <paramref name="source"/>.</returns>
 /// <exception cref="System.ArgumentNullException"><paramref name="source"/> is null.</exception>
 public static TSource FirstOrDefault <TSource>(this IEnumerable <TSource> source, TSource @default)
 {
     return(DDRIT.FirstOrDefault(source, @default));
 }
コード例 #25
0
 public static String FilePathToUri(this String path)
 {
     return(DDRIT.FilePathToUri(path));
 }
コード例 #26
0
 /// <typeparam name="TSource"></typeparam>
 /// <param name="source">The System.Collections.Generic.IEnumerable&lt;<typeparamref name="TSource"/>&gt; to return the first element of.</param>
 /// <param name="default">The default value to return if the source is empty.</param>
 /// <returns><paramref name="default"/> if <paramref name="source"/> is empty or if no element passes the test specified by <paramref name="predicate"/>;
 /// otherwise, the first element in <paramref name="source"/> that passes the test specified by <param name="predicate"/>.</returns>
 /// <exception cref="System.ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
 public static TSource FirstOrDefault <TSource>(this IEnumerable <TSource> source, Func <TSource, Boolean> predicate, TSource @default)
 {
     return(DDRIT.FirstOrDefault(source, predicate, @default));
 }
コード例 #27
0
 /// <summary>
 /// Attempt to deserialize any Binary Encoded string into an object.
 /// </summary>
 /// <typeparam name="TResult">The type to convert to.</typeparam>
 /// <param name="input">The string to deserialize to an object.</param>
 /// <returns>An Object of type T deserialized from the string.</returns>
 public static TResult FromBinary <TResult>(this String input)
 {
     return(DDRIT.FromBinary <TResult>(input));
 }
コード例 #28
0
 /// <summary>
 /// Trim markup to the longest string of whole words, under a particular length, and append an elipsis if there is truncated content.
 /// If the length is shorter than the first whole word, then returns the first whole word, and appends an elipsis if there is truncated content.
 /// </summary>
 /// <param name="input">The content to trim</param>
 /// <param name="maxLength">The maximum length of the returned content</param>
 /// <param name="stripTags">(true)Remove HTML tags before trimming</param>
 /// <returns></returns>
 public static String TrimTo(this String input, Int32 maxLength, Boolean stripTags = true)
 {
     return(DDRIT.TrimTo(input, maxLength, stripTags));
 }
コード例 #29
0
 /// <summary>
 /// Attempt to deserialize any Binary Encoded string into an object.
 /// </summary>
 /// <param name="input">The string to deserialize to an object.</param>
 /// <param name="type">The type to convert to.</param>
 /// <returns>An Object deserialized from the string.</returns>
 public static Object FromBinary(this String input)
 {
     return(DDRIT.FromBinary(input));
 }
コード例 #30
0
 public static TimeSpan ToTimeSpan(this String input, TimeSpan @default)
 {
     return(DDRIT.ToTimeSpan(input, @default));
 }