Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The SfcKey class is the base class for all nested Key classes which every SfcInstance-derived object must have. It implements equality and hashing but not comparison, since Keys are only required to know if they are equal or not.
Keys are meant to be immutable once constructed, hence a Key should not contain data which can change during the Key object's lifetime. Do not use field(s) as part of a Key which are not truly part of the identity the Key represents. We may enforce this by disallowing set() on the internal properties for the Key.
Any ordering or collation needs are addressed by implementing:
- IComparable on the SfcKey-derived class
- IComparer or IComparer<T> on the SfcCollection-derived collection class
public abstract class SfcKey : IEquatable<Microsoft.SqlServer.Management.Sdk.Sfc.SfcKey>
type SfcKey = class interface IEquatable<SfcKey>
Public MustInherit Class SfcKey Implements IEquatable(Of SfcKey)
The Type of the instance class associated with this key class. Default impl is the way a nested key class would do it for compatiblity with existing models using that technique. This should be overriden in any key class which is not a nested class of the instance type.
Each Key must do proper value comparison of its data members. Do not rely solely on reference equality checking like object does.
Each Key must provide a reasonable hash code for its data members. Internally, strings can use their default hash codes, and numeric values can be used directly or bit-shifted and truncated to int. Multiple hash codes for internal data can usually be XOR'd together to produce a decent result.
Each Key must implement how to produce a valid XPath-oriented identity string fragmentwhich is used to build complete and valid Urn from a SfcKeyChain of Key.