Partilhar via


GraphNodeId Class

Definition

A GraphNodeId is a name/value pair, for example "a=b". The left part of this identifier ("a") is represented by a GraphNodeIdName called the "Name" and the right hand side, "b" is the "Value" part. The value part of a GraphNodeId can be one of the following: * String * Uri * GraphNodeId * GraphNodeIdCollection Since the Value can be a GraphNodeId or GraphNodeIdCollection, we can use parentheses "()" to specify Nesting: e.g. a=(b=c) a=(b=c d=e) (a=b c=d) To construct a nested GraphNodeId list for (a=b c=d), create an GraphNodeIdCollection and assign it to a GraphNodeId:

GraphNodeId.Get(GraphNodeIdName.Nested, new GraphNodeIdCollection(
    GraphNodeId.Get(MyGraphNodeIdNames.a, "b")
    GraphNodeId.Get(MyGraphNodeIdNames.c, "d"));

You can also create this GraphNodeId using the following simple arithmetic:

GraphNodeId ab = GraphNodeId.Get("(a=b)");
GraphNodeId abcd = ab + "(c=d)";  // Yields (a=b c=d)

The result can be converted to a string using ToString() or implicit string cast operator and will produce "(a=b c=d)".

Since GraphNodeIds are stored singleton in a HashSet, they can be compared using operator ==
public ref class GraphNodeId : IComparable, IComparable<Microsoft::VisualStudio::GraphModel::GraphNodeId ^>, IEquatable<Microsoft::VisualStudio::GraphModel::GraphNodeId ^>, IEquatable<Microsoft::VisualStudio::GraphModel::IGraphNodeIdKey ^>
[System.ComponentModel.TypeConverter(typeof(Microsoft.VisualStudio.GraphModel.GraphNodeIdConverter))]
[System.Serializable]
public class GraphNodeId : IComparable, IComparable<Microsoft.VisualStudio.GraphModel.GraphNodeId>, IEquatable<Microsoft.VisualStudio.GraphModel.GraphNodeId>, IEquatable<Microsoft.VisualStudio.GraphModel.IGraphNodeIdKey>
[<System.ComponentModel.TypeConverter(typeof(Microsoft.VisualStudio.GraphModel.GraphNodeIdConverter))>]
[<System.Serializable>]
type GraphNodeId = class
    interface IEquatable<IGraphNodeIdKey>
    interface IEquatable<GraphNodeId>
    interface IComparable<GraphNodeId>
    interface IComparable
Public Class GraphNodeId
Implements IComparable, IComparable(Of GraphNodeId), IEquatable(Of GraphNodeId), IEquatable(Of IGraphNodeIdKey)
Inheritance
GraphNodeId
Attributes
Implements
IComparable IComparable<GraphNodeId> IEquatable<GraphNodeId> IEquatable<Microsoft.VisualStudio.GraphModel.IGraphNodeIdKey>

Properties

Empty
LiteralValue

Gets a literal value for the GraphNodeId. Uses the Name if the GraphNodeIdName is a Literal otherwise delegates to ToString.

Name

The GraphNodeIdName

Value

The value of the GraphNodeId - can be one of:

  • String
  • Uri
  • GraphNodeId
  • GraphNodeIdCollection

Methods

Add(GraphNodeId)

Adds a GraphNodeId. If this identifier already is an array, the item is added to the array, otherwise a new embedded array is returned.

AppendToString(StringBuilder)

Appends the "ToString" of a GraphNodeId to the StringBuilder. This is more efficient than calling ToString, as the GraphNodeId can re-use the StringBuilder;

CompareTo(GraphNodeId)

Compares to another GraphNodeId

CompareTo(Object)

Compares to another GraphNodeId

Equals(Object)

See if this GraphNodeId match either a GraphNodeId or a GraphNodeIdKey.

GetArray(GraphNodeIdName, GraphNodeId[])

Constructs a partial GraphNodeId based on the given array name and identifiers

GetArray(GraphNodeIdName, Object)

Get a GraphNodeId based on the name and value. Does a lookup against a Dictionary to minimize the number of GraphNodeIds around.

GetHashCode()

Get the HashCode. We return the hashcode given to us during construction.

GetLiteral(String)

Gets a literal GraphNodeId parsed from the given identifier string

GetNested(GraphNodeId[])

Get a nested GraphNodeId based on the given identifiers. Does a lookup against a Dictionary to minimize the number of GraphNodeIds around.

GetNested(GraphNodeIdName, Object)

Get a GraphNodeId based on the name and value. Does a lookup against a Dictionary to minimize the number of GraphNodeIds around.

GetNestedIdByName(GraphNodeIdName)

Gets a value from the first embedded GraphNodeId that matches the name

GetNestedValueByName<T>(GraphNodeIdName)

Gets a value from the first embedded GraphNodeId that matches the name

GetPartial(GraphNodeIdName, Object)

Gets a partial GraphNodeId based on the name and value. Does a lookup against a Dictionary to minimize the number of GraphNodeIds around. It is generally not right to get a partial GraphNodeId and use it for a node id. Always use a full Nested GraphNodeId;

GetValue<T>()

The value of the GraphNodeId - can be one of:

  • String
  • Uri
  • GraphNodeId
  • GraphNodeIdCollection
IsNullOrEmpty(GraphNodeId)
Parse(String, Boolean, Func<Int32,GraphNodeId>)

Parse a string into a GraphNodeId

Parse(String, Boolean)

Parse a string into a GraphNodeId

Parse(String)

Parse a string into a GraphNodeId

RemovedNestedNames(GraphNodeIdName[])

Returns a partial GraphNodeId containing the given GraphNodeIdName

ToString()

Gets a string for the GraphNodeId

Operators

Addition(GraphNodeId, GraphNodeId)

The + operator adds two GraphNodeIds. If either GraphNodeId is already contain an array, the item is added to the array, otherwise a new embedded array is returned.

Equality(GraphNodeId, GraphNodeId)

The == operator compares two GraphNodeIds and return whether they're equal

Inequality(GraphNodeId, GraphNodeId)

The != operator compares two GraphNodeIds and return whether they're equal

Explicit Interface Implementations

IEquatable<GraphNodeId>.Equals(GraphNodeId)

Our implementation of IEquatable<GraphNodeIdKey>.Equals. We use explicit interface implementation in order to keep the IGraphNodeIdKey private.

IEquatable<IGraphNodeIdKey>.Equals(IGraphNodeIdKey)

Our implementation of IEquatable<IGraphNodeIdKey>.Equals. We use explicit interface implementation in order to keep the IGraphNodeIdKey private.

Applies to