Show / Hide Table of Contents

    Class ExtensionMethods

    Holds all Extension methods that are used throughout the framework

    Inheritance
    System.Object
    ExtensionMethods
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: OPTANO.Modeling.Common
    Assembly: Common.dll
    Syntax
    public static class ExtensionMethods

    Methods

    CartesianProduct<T>(IEnumerable<IEnumerable<T>>)

    Cartesians the product.

    Declaration
    public static IEnumerable<IEnumerable<T>> CartesianProduct<T>(this IEnumerable<IEnumerable<T>> sequences)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<T>> sequences

    The sequences.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<T>>

    The cartesian product of all System.Collections.Generic.IEnumerable<T>s.

    Type Parameters
    Name Description
    T

    The element type

    Clone<T>(T)

    Clones an object by serializing and deserializing it, therefore it needs to be System.Runtime.Serialization.ISerializable"/>.

    Declaration
    public static T Clone<T>(this T source)
    Parameters
    Type Name Description
    T source

    The object to clone

    Returns
    Type Description
    T

    The T.

    Type Parameters
    Name Description
    T

    The type of the object to clone

    Exceptions
    Type Condition
    System.ArgumentException

    Throws an execption, if the object is not serializable.

    ConvertFromBase64Index(String)

    Converts a short index string into a index number

    Declaration
    public static long ConvertFromBase64Index(this string index64)
    Parameters
    Type Name Description
    System.String index64

    short index string, similar to base64

    Returns
    Type Description
    System.Int64

    index number

    ConvertToBase64Index(Int32)

    Converts the given index into a short index string.

    Declaration
    public static string ConvertToBase64Index(this int index)
    Parameters
    Type Name Description
    System.Int32 index

    Any valid index number

    Returns
    Type Description
    System.String

    The short index string

    ConvertToBase64Index(Int64)

    Converts the given index into a short index string.

    Declaration
    public static string ConvertToBase64Index(this long index)
    Parameters
    Type Name Description
    System.Int64 index

    Any valid index number

    Returns
    Type Description
    System.String

    The short index string

    ForEach<T>(IEnumerable<T>, Action<T>)

    Executes action on every element of source

    Declaration
    public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> source

    The source.

    System.Action<T> action

    The action.

    Type Parameters
    Name Description
    T

    The type.

    GetCasePermutations(String)

    Computes all lower-/upper case permutations for the given word. E.g. for the input "foo".

    Declaration
    public static IEnumerable<string> GetCasePermutations(this string word)
    Parameters
    Type Name Description
    System.String word

    The input string.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.String>

    An enumerable of all case permutations.

    IsFiniteValue(Double)

    Checks if the value is not System.Double.NaN, or System.Double.IsInfinity(System.Double)

    Declaration
    public static bool IsFiniteValue(this double value)
    Parameters
    Type Name Description
    System.Double value

    The value to check.

    Returns
    Type Description
    System.Boolean

    true, iff System.Double.NegativeInfinity < value < System.Double.PositiveInfinity

    IsFiniteValue(Nullable<Double>)

    Checks if the value is not null, System.Double.NaN, or System.Double.IsInfinity(System.Double)

    Declaration
    public static bool IsFiniteValue(this double? value)
    Parameters
    Type Name Description
    System.Nullable<System.Double> value

    The value to check.

    Returns
    Type Description
    System.Boolean

    true, iff System.Double.NegativeInfinity < value < System.Double.PositiveInfinity

    IsInteger(Double, Double)

    Determines whether the specified value is an integer value

    Declaration
    public static bool IsInteger(this double value, double epsilon = 1E-06)
    Parameters
    Type Name Description
    System.Double value

    The value.

    System.Double epsilon

    The comparison tolerance.

    Returns
    Type Description
    System.Boolean

    true if the specified value is long; otherwise, false.

    MultiplyElements(IEnumerable<Double>)

    Multiplies the elements and returns the result.

    Declaration
    public static double MultiplyElements(this IEnumerable<double> source)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.Double> source

    The source.

    Returns
    Type Description
    System.Double

    The product of all elements in the source.

    RemoveUnsupportedCharacters(String)

    Removes unsupported characters and only leaves letters, numbers and underscore.

    Declaration
    public static string RemoveUnsupportedCharacters(this string text)
    Parameters
    Type Name Description
    System.String text

    text to filter

    Returns
    Type Description
    System.String

    SanitizeName(String)

    Removes all characters that might lead to conflicts when name is passed to MIP Solvers.

    Declaration
    public static string SanitizeName(this string name)
    Parameters
    Type Name Description
    System.String name

    The name.

    Returns
    Type Description
    System.String

    The sanitized name.

    ShallowCopy<TKey, TValue>(IDictionary<TKey, TValue>)

    Creates a shallow copy of the dictionary.

    Declaration
    public static Dictionary<TKey, TValue> ShallowCopy<TKey, TValue>(this IDictionary<TKey, TValue> dict)
    Parameters
    Type Name Description
    System.Collections.Generic.IDictionary<TKey, TValue> dict

    The dictionary to copy.

    Returns
    Type Description
    System.Collections.Generic.Dictionary<TKey, TValue>
    Type Parameters
    Name Description
    TKey

    The key type.

    TValue

    The value type.

    ThrowIfArgumentIsNull<T>(T, String)

    Throws an System.ArgumentNullException if the object is null.

    Declaration
    public static void ThrowIfArgumentIsNull<T>(this T value, string argument)
        where T : class
    Parameters
    Type Name Description
    T value

    The System.Object to check

    System.String argument

    The name of the parameter in which value was passed.

    Type Parameters
    Name Description
    T

    The type of value.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Thrown, if value is null.

    TruncateToLength(String, Int32)

    Cuts a string to the given length if text is longer

    Declaration
    public static string TruncateToLength(this string text, int limit = 254)
    Parameters
    Type Name Description
    System.String text

    Given Text

    System.Int32 limit

    maximum length

    Returns
    Type Description
    System.String

    Truncated text

    Back to top Copyright © OPTANO GmbH generated with DocFX
    Privacy Policy | Impressum – Legal Notice