Class ObjectTypeGraphBuilder
Builds immutable object-type graphs, including recursive graphs.
public sealed class ObjectTypeGraphBuilder
- Inheritance
-
ObjectTypeGraphBuilder
- Inherited Members
Constructors
ObjectTypeGraphBuilder()
public ObjectTypeGraphBuilder()
Methods
AddProperty(ObjectTypeGraphReference, string, ObjectTypeGraphReference, bool, bool)
Adds a property to a declared object type.
public ObjectTypeGraphBuilder AddProperty(ObjectTypeGraphReference objectType, string name, ObjectTypeGraphReference propertyType, bool isOptional = false, bool isReadOnly = false)
Parameters
objectTypeObjectTypeGraphReferenceThe declared object type.
namestringThe property name.
propertyTypeObjectTypeGraphReferenceThe property type expression.
isOptionalboolWhether the property may be omitted.
isReadOnlyboolWhether the property value and presence are read-only.
Returns
- ObjectTypeGraphBuilder
The same ObjectTypeGraphBuilder instance, for chaining.
Exceptions
- ArgumentException
Thrown when a reference is invalid or the property is duplicated.
- ArgumentNullException
Thrown when an argument is
null.- InvalidOperationException
Thrown after the builder has been finalized.
Array(ObjectTypeGraphReference)
Creates a mutable-array type expression.
public ObjectTypeGraphReference Array(ObjectTypeGraphReference elementType)
Parameters
elementTypeObjectTypeGraphReferenceThe element type expression.
Returns
- ObjectTypeGraphReference
An opaque reference to the mutable-array type.
Exceptions
- ArgumentException
Thrown when the reference belongs to another builder.
- ArgumentNullException
Thrown when
elementTypeisnull.- InvalidOperationException
Thrown after the builder has been finalized.
Build()
Finalizes the complete type graph.
public IReadOnlyDictionary<ObjectTypeGraphReference, TypeSymbol> Build()
Returns
- IReadOnlyDictionary<ObjectTypeGraphReference, TypeSymbol>
An immutable mapping from graph references to completed types.
Exceptions
- ArgumentException
Thrown when a type expression is invalid.
- InvalidOperationException
Thrown when the builder was already finalized.
DeclareAnonymous(string, bool)
Declares an anonymous object type.
public ObjectTypeGraphReference DeclareAnonymous(string key, bool isOpen)
Parameters
Returns
- ObjectTypeGraphReference
An opaque reference to the declared type.
Exceptions
- ArgumentException
Thrown when
keyis invalid or duplicated.- InvalidOperationException
Thrown after the builder has been finalized.
DeclareNamed(string, string, string, bool)
Declares a named object type.
public ObjectTypeGraphReference DeclareNamed(string key, string id, string name, bool isOpen)
Parameters
keystringThe builder-local key.
idstringThe provider type identifier.
namestringThe language-facing name.
isOpenboolWhether undeclared properties are permitted.
Returns
- ObjectTypeGraphReference
An opaque reference to the declared type.
Exceptions
- ArgumentException
Thrown when a value is invalid or duplicated.
- InvalidOperationException
Thrown after the builder has been finalized.
From(TypeSymbol)
Creates a reference to an existing type.
public ObjectTypeGraphReference From(TypeSymbol type)
Parameters
typeTypeSymbolThe existing type.
Returns
- ObjectTypeGraphReference
An opaque reference to the type.
Exceptions
- ArgumentNullException
Thrown when
typeisnull.- InvalidOperationException
Thrown after the builder has been finalized.
Nullable(ObjectTypeGraphReference)
Creates a nullable type expression.
public ObjectTypeGraphReference Nullable(ObjectTypeGraphReference underlyingType)
Parameters
underlyingTypeObjectTypeGraphReferenceThe underlying type expression.
Returns
- ObjectTypeGraphReference
An opaque reference to the nullable type.
Exceptions
- ArgumentException
Thrown when the reference belongs to another builder.
- ArgumentNullException
Thrown when
underlyingTypeisnull.- InvalidOperationException
Thrown after the builder has been finalized.
ReadOnlyArray(ObjectTypeGraphReference)
Creates a read-only-array type expression.
public ObjectTypeGraphReference ReadOnlyArray(ObjectTypeGraphReference elementType)
Parameters
elementTypeObjectTypeGraphReferenceThe element type expression.
Returns
- ObjectTypeGraphReference
An opaque reference to the read-only-array type.
Exceptions
- ArgumentException
Thrown when the reference belongs to another builder.
- ArgumentNullException
Thrown when
elementTypeisnull.- InvalidOperationException
Thrown after the builder has been finalized.