Table of Contents

Class Constant

Namespace
AsmResolver.DotNet
Assembly
AsmResolver.DotNet.dll

Represents a literal value that is assigned to a field, parameter or property.

public class Constant : MetadataMember, IMetadataMember
Inheritance
Constant
Implements
Derived
Inherited Members

Constructors

Constant(ElementType, DataBlobSignature?)

Creates a new constant for a member, with the provided constant type and raw literal value.

public Constant(ElementType type, DataBlobSignature? value)

Parameters

type ElementType

The type of the constant.

value DataBlobSignature

The raw literal value of the constant.

Constant(MetadataToken)

Initializes the constant with a metadata token.

protected Constant(MetadataToken token)

Parameters

token MetadataToken

The metadata token.

Properties

Parent

Gets the member that is assigned a constant.

public IHasConstant? Parent { get; }

Property Value

IHasConstant

Type

Gets the type of constant that is stored in the blob stream.

public ElementType Type { get; set; }

Property Value

ElementType

Remarks

This field must always be a value-type.

Value

Gets or sets the serialized literal value.

public DataBlobSignature? Value { get; set; }

Property Value

DataBlobSignature

Methods

FromValue(bool)

Create a Constant from a value

public static Constant FromValue(bool value)

Parameters

value bool

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(byte)

Create a Constant from a value

public static Constant FromValue(byte value)

Parameters

value byte

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(char)

Create a Constant from a value

public static Constant FromValue(char value)

Parameters

value char

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(double)

Create a Constant from a value

public static Constant FromValue(double value)

Parameters

value double

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(short)

Create a Constant from a value

public static Constant FromValue(short value)

Parameters

value short

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(int)

Create a Constant from a value

public static Constant FromValue(int value)

Parameters

value int

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(long)

Create a Constant from a value

public static Constant FromValue(long value)

Parameters

value long

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(sbyte)

Create a Constant from a value

public static Constant FromValue(sbyte value)

Parameters

value sbyte

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(float)

Create a Constant from a value

public static Constant FromValue(float value)

Parameters

value float

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(string)

Create a Constant from a value

public static Constant FromValue(string value)

Parameters

value string

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(ushort)

Create a Constant from a value

public static Constant FromValue(ushort value)

Parameters

value ushort

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(uint)

Create a Constant from a value

public static Constant FromValue(uint value)

Parameters

value uint

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

FromValue(ulong)

Create a Constant from a value

public static Constant FromValue(ulong value)

Parameters

value ulong

The value to be assigned to the constant

Returns

Constant

A new Constant with the correct Type and Value

GetParent()

Obtains the owner of the constant.

protected virtual IHasConstant? GetParent()

Returns

IHasConstant

The parent.

Remarks

This method is called upon initialization of the Parent property.

GetValue()

Obtains the literal value of the constant.

protected virtual DataBlobSignature? GetValue()

Returns

DataBlobSignature

The value.

Remarks

This method is called upon initialization of the Value property.