Class Udi
Represents an entity identifier.
Inheritance
Namespace: Umbraco.Core
Assembly: Umbraco.Core.dll
Syntax
[TypeConverter(typeof(UdiTypeConverter))]
public abstract class Udi : IComparable<Udi>
Remarks
An Udi can be fully qualified or "closed" eg umb://document/{guid} or "open" eg umb://document.
Constructors
View SourceUdi(String, String)
Initializes a new instance of the Udi class.
Declaration
protected Udi(string entityType, string stringValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | entityType | The entity type part of the identifier. |
System.String | stringValue | The string value of the identifier. |
Udi(Uri)
Initializes a new instance of the Udi class.
Declaration
protected Udi(Uri uriValue)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uriValue | The uri value of the identifier. |
Properties
View SourceEntityType
Gets the entity type part of the identifier.
Declaration
public string EntityType { get; }
Property Value
Type | Description |
---|---|
System.String |
IsRoot
Gets a value indicating whether this Udi is a root Udi.
Declaration
public abstract bool IsRoot { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
A root Udi points to the "root of all things" for a given entity type, e.g. the content tree root.
Methods
View SourceCompareTo(Udi)
Declaration
public int CompareTo(Udi other)
Parameters
Type | Name | Description |
---|---|---|
Udi | other |
Returns
Type | Description |
---|---|
System.Int32 |
Create(String)
Creates a root Udi for an entity type.
Declaration
public static Udi Create(string entityType)
Parameters
Type | Name | Description |
---|---|---|
System.String | entityType | The entity type. |
Returns
Type | Description |
---|---|
Udi | The root Udi for the entity type. |
Create(String, Guid)
Creates a Guid Udi.
Declaration
public static Udi Create(string entityType, Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.String | entityType | The entity type. |
System.Guid | id | The identifier. |
Returns
Type | Description |
---|---|
Udi | The Guid Udi for the entity type and identifier. |
Create(String, String)
Creates a string Udi.
Declaration
public static Udi Create(string entityType, string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | entityType | The entity type. |
System.String | id | The identifier. |
Returns
Type | Description |
---|---|
Udi | The string Udi for the entity type and identifier. |
EnsureNotRoot()
Ensures that this Udi is not a root Udi.
Declaration
public Udi EnsureNotRoot()
Returns
Type | Description |
---|---|
Udi | This Udi. |
Exceptions
Type | Condition |
---|---|
System.Exception | When this Udi is a Root Udi. |
EnsureType(String[])
Declaration
public void EnsureType(params string[] validTypes)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | validTypes |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Parse(String)
Converts the string representation of an entity identifier into the equivalent Udi instance.
Declaration
public static Udi Parse(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to convert. |
Returns
Type | Description |
---|---|
Udi | An Udi instance that contains the value that was parsed. |
Parse(String, Boolean)
Converts the string representation of an entity identifier into the equivalent Udi instance.
Declaration
public static Udi Parse(string s, bool knownTypes)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to convert. |
System.Boolean | knownTypes | A value indicating whether to only deal with known types. |
Returns
Type | Description |
---|---|
Udi | An Udi instance that contains the value that was parsed. |
Remarks
If knownTypes
is true
, and the string could not be parsed because
the entity type was not known, the method succeeds but sets udi
to an
Umbraco.Core.Udi.UnknownTypeUdi value.
If knownTypes
is true
, assemblies are not scanned for types,
and therefore only builtin types may be known. Unless scanning already took place.
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
TryParse(String, Boolean, out Udi)
Converts the string representation of an entity identifier into the equivalent Udi instance.
Declaration
public static bool TryParse(string s, bool knownTypes, out Udi udi)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to convert. |
System.Boolean | knownTypes | A value indicating whether to only deal with known types. |
Udi | udi | An Udi instance that contains the value that was parsed. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean value indicating whether the string could be parsed. |
Remarks
If knownTypes
is true
, and the string could not be parsed because
the entity type was not known, the method returns false
but still sets udi
to an Umbraco.Core.Udi.UnknownTypeUdi value.
If knownTypes
is true
, assemblies are not scanned for types,
and therefore only builtin types may be known. Unless scanning already took place.
TryParse(String, out Udi)
Converts the string representation of an entity identifier into the equivalent Udi instance.
Declaration
public static bool TryParse(string s, out Udi udi)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to convert. |
Udi | udi | An Udi instance that contains the value that was parsed. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean value indicating whether the string could be parsed. |
Operators
View SourceEquality(Udi, Udi)
Declaration
public static bool operator ==(Udi udi1, Udi udi2)
Parameters
Type | Name | Description |
---|---|---|
Udi | udi1 | |
Udi | udi2 |
Returns
Type | Description |
---|---|
System.Boolean |
Inequality(Udi, Udi)
Declaration
public static bool operator !=(Udi udi1, Udi udi2)
Parameters
Type | Name | Description |
---|---|---|
Udi | udi1 | |
Udi | udi2 |
Returns
Type | Description |
---|---|
System.Boolean |