Struct ObjectId
A hash to uniquely identify data.
[DataContract("ObjectId")]
[Serializable]
[DataSerializer(typeof(ObjectId.Serializer))]
public struct ObjectId : IEquatable<ObjectId>, IComparable<ObjectId>
- Implements
Constructors
ObjectId(byte[])
Initializes a new instance of the ObjectId struct.
public ObjectId(byte[] hash)
Parameters
hash
byte[]The hash.
Exceptions
- ArgumentNullException
hash
- InvalidOperationException
ObjectId value doesn't match expected size.
ObjectId(uint, uint, uint, uint)
public ObjectId(uint hash1, uint hash2, uint hash3, uint hash4)
Parameters
Fields
Empty
public static readonly ObjectId Empty
Field Value
HashSize
public const int HashSize = 16
Field Value
HashStringLength
public const int HashStringLength = 32
Field Value
Methods
Combine(ObjectId, ObjectId)
public static ObjectId Combine(ObjectId left, ObjectId right)
Parameters
Returns
Combine(ref ObjectId, ref ObjectId, out ObjectId)
public static void Combine(ref ObjectId left, ref ObjectId right, out ObjectId result)
Parameters
CompareTo(ObjectId)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(ObjectId other)
Parameters
other
ObjectIdAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes other
in the sort order.Zero This instance occurs in the same position in the sort order as other
.Greater than zero This instance follows other
in the sort order.
Equals(ObjectId)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(ObjectId other)
Parameters
other
ObjectIdAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
FromBytes(byte[])
Computes a hash from a byte buffer.
public static ObjectId FromBytes(byte[] buffer)
Parameters
buffer
byte[]The byte buffer.
Returns
- ObjectId
The hash of the object.
Exceptions
- ArgumentNullException
buffer
FromBytes(byte[], int, int)
Computes a hash from a byte buffer.
public static ObjectId FromBytes(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]The byte buffer.
offset
intThe offset into the buffer.
count
intThe number of bytes to read from the buffer starting at offset position.
Returns
- ObjectId
The hash of the object.
Exceptions
- ArgumentNullException
buffer
FromObject<T>(T)
Computes a hash from an object using BinarySerializationWriter.
public static ObjectId FromObject<T>(T obj)
Parameters
obj
TThe object.
Returns
- ObjectId
The hash of the object.
Type Parameters
T
FromObject<T>(T, out byte[])
Computes a hash from an object using BinarySerializationWriter.
public static ObjectId FromObject<T>(T obj, out byte[] buffer)
Parameters
obj
TThe object.
buffer
byte[]The buffer containing the serialized object.
Returns
- ObjectId
The hash of the object.
Type Parameters
T
The type of the object to serialize
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
New()
News this instance.
public static ObjectId New()
Returns
- ObjectId
ObjectId.
ToGuid()
Gets a Guid from this object identifier.
public Guid ToGuid()
Returns
- Guid
Guid.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
TryParse(string, out ObjectId)
Tries to parse an ObjectId from a string.
public static bool TryParse(string input, out ObjectId result)
Parameters
Returns
- bool
true
if parsing was successfull,false
otherwise
Operators
operator ==(ObjectId, ObjectId)
Implements the ==.
public static bool operator ==(ObjectId left, ObjectId right)
Parameters
Returns
- bool
The result of the operator.
explicit operator byte[](ObjectId)
public static explicit operator byte[](ObjectId objectId)
Parameters
objectId
ObjectIdThe object id.
Returns
- byte[]
The result of the conversion.
explicit operator ObjectId(Guid)
public static explicit operator ObjectId(Guid guid)
Parameters
guid
Guid
Returns
operator !=(ObjectId, ObjectId)
Implements the !=.
public static bool operator !=(ObjectId left, ObjectId right)
Parameters
Returns
- bool
The result of the operator.