Search Results for

    Show / Hide Table of Contents

    Struct Conversion

    Inherited Members
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    Object.Equals(Object, Object)
    Object.GetType()
    Object.ReferenceEquals(Object, Object)
    Namespace: Microsoft.ML.Probabilistic.Compiler.Reflection
    Assembly: Microsoft.ML.Probabilistic.Compiler.dll
    Syntax
    public struct Conversion

    Fields

    ChangeRankSubclassCount

    Declaration
    public const int ChangeRankSubclassCount = 3000
    Field Value
    Type Description
    Int32

    Converter

    Declaration
    public Converter Converter
    Field Value
    Type Description
    Converter

    IsExplicit

    True if the conversion is explicit.

    Declaration
    public bool IsExplicit
    Field Value
    Type Description
    Boolean
    Remarks

    Must be false if converter is null. An implicit conversion must always succeed and does not lose information. Otherwise, it is explicit.

    OpImplicitSubclassCount

    Declaration
    public const int OpImplicitSubclassCount = 2000
    Field Value
    Type Description
    Int32

    SameTypeCodeSubclassCount

    Declaration
    public const int SameTypeCodeSubclassCount = 1000
    Field Value
    Type Description
    Int32

    SpecialImplicitSubclassCount

    Declaration
    public const int SpecialImplicitSubclassCount = 10000
    Field Value
    Type Description
    Int32

    SubclassCount

    The number of subclass edges between the two types.

    Declaration
    public int SubclassCount
    Field Value
    Type Description
    Int32
    Remarks

    This is only valid if converter is null, i.e. no conversion is needed.
    If the two types are the same, then SubclassCount == 0.
    If one is a direct subclass of the other, SubclassCount == 1. If one is a subclass of a subclass of the other, SubclassCount == 2, and so on.

    Methods

    ChangeRank(Array, Int32, Type, Converter)

    Change array rank and convert elements.

    Declaration
    public static Array ChangeRank(Array fromArray, int toRank, Type toElementType, Converter conv)
    Parameters
    Type Name Description
    Array fromArray
    Int32 toRank

    Can be smaller, larger, or equal to fromArray.Rank.

    Type toElementType
    Converter conv
    Returns
    Type Description
    Array

    A new array of rank toRank with the same contents as fromArray.

    ChangeType(Object, Type)

    Declaration
    public static object ChangeType(object value, Type toType)
    Parameters
    Type Name Description
    Object value
    Type toType
    Returns
    Type Description
    Object

    ConvertDelegate(Type, Delegate)

    Convert a weakly-typed delegate into a strongly-typed delegate.

    Declaration
    public static Delegate ConvertDelegate(Type delegateType, Delegate inner)
    Parameters
    Type Name Description
    Type delegateType

    The desired delegate type.

    Delegate inner

    A delegate with parameters (object[] args). The return type can be any type convertible to the return type of delegateType, or void if the delegateType is void.

    Returns
    Type Description
    Delegate

    A delegate of type delegateType. The arguments of this delegate will be passed as (object[]) args to the innerMethod.

    GetPrimitiveConverter(Type, Type)

    Declaration
    public static Converter GetPrimitiveConverter(Type fromType, Type toType)
    Parameters
    Type Name Description
    Type fromType
    Type toType
    Returns
    Type Description
    Converter

    GetWeight()

    Returns a numerical weight such that (a.GetWeight() < b.GetWeight()) iff (a < b)

    Declaration
    public float GetWeight()
    Returns
    Type Description
    Single

    GetWeight(IEnumerable<Conversion>)

    Declaration
    public static float GetWeight(IEnumerable<Conversion> array)
    Parameters
    Type Name Description
    IEnumerable<Conversion> array
    Returns
    Type Description
    Single

    IsNullable(Type)

    Declaration
    public static bool IsNullable(Type type)
    Parameters
    Type Name Description
    Type type
    Returns
    Type Description
    Boolean

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    ValueType.ToString()

    TryGetArrayConversion(Int32, Int32, Type, Conversion, out Conversion)

    Declaration
    public static bool TryGetArrayConversion(int fromRank, int toRank, Type toElementType, Conversion elementConversion, out Conversion info)
    Parameters
    Type Name Description
    Int32 fromRank
    Int32 toRank
    Type toElementType
    Conversion elementConversion
    Conversion info
    Returns
    Type Description
    Boolean

    TryGetConversion(Type, Type, out Conversion)

    Get a type converter.

    Declaration
    public static bool TryGetConversion(Type fromType, Type toType, out Conversion info)
    Parameters
    Type Name Description
    Type fromType

    non-null. May contain type parameters. Use typeof(Nullable) to convert from a null value.

    Type toType

    non-null. May contain type parameters. May be typeof(void), for which no conversion is needed.

    Conversion info
    Returns
    Type Description
    Boolean

    null if no converter was found.

    TryGetPrimitiveConversion(Type, Type, out Conversion)

    Get a Conversion structure to a primitive type.

    Declaration
    public static bool TryGetPrimitiveConversion(Type fromType, Type toType, out Conversion info)
    Parameters
    Type Name Description
    Type fromType

    Any type.

    Type toType

    A primitive type.

    Conversion info
    Returns
    Type Description
    Boolean

    false if no conversion exists.

    Operators

    GreaterThan(Conversion, Conversion)

    Declaration
    public static bool operator>(Conversion a, Conversion b)
    Parameters
    Type Name Description
    Conversion a
    Conversion b
    Returns
    Type Description
    Boolean

    LessThan(Conversion, Conversion)

    True if A is a more specific conversion than B.

    Declaration
    public static bool operator <(Conversion a, Conversion b)
    Parameters
    Type Name Description
    Conversion a
    Conversion b
    Returns
    Type Description
    Boolean

    True if A is a more specific conversion than B.

    Remarks

    The following criteria are applied in order:

    1. A null conversion versus a non-null conversion.
    2. Among null conversions, the one crossing fewer subclass links.
    3. An implicit conversion versus an explicit conversion.
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.