示例#1
0
 /// <summary>
 /// Creates a new member path segment, with a given binding key.
 /// </summary>
 /// <param name="bindingKey">The binding key of the member to access.</param>
 public StonMemberPathSegment(IStonBindingKey bindingKey)
 {
     if (bindingKey == null)
     {
         throw new ArgumentNullException("bindingKey");
     }
     BindingKey = StonBindingKey.Copy(bindingKey);
 }
示例#2
0
 /// <summary>
 /// Creates a structurally equivalent member binding key from a given binding key.
 /// </summary>
 /// <param name="bindingKey">The binding key to copy the structure of.</param>
 /// <returns>A structurally equivalent copy of the given binding key.</returns>
 public static IStonBindingKey Copy(IStonBindingKey bindingKey)
 {
     if (bindingKey == null)
     {
         throw new ArgumentNullException("bindingKey");
     }
     if (bindingKey is IStonBindingName)
     {
         return(StonBindingName.Copy(bindingKey as IStonBindingName));
     }
     if (bindingKey is IStonBindingIndex)
     {
         return(StonBindingIndex.Copy(bindingKey as IStonBindingIndex));
     }
     throw new StonImplementationException(bindingKey.GetType(), typeof(IStonBindingKey), typeof(IStonBindingName), typeof(IStonBindingIndex));
 }
示例#3
0
 /// <summary>
 /// Checks the validity of a given STON member binding key.
 /// </summary>
 /// <param name="bindingKey">The member binding key to check the validity of.</param>
 public static void ValidateBindingKey(IStonBindingKey bindingKey)
 {
     if (bindingKey == null)
     {
         throw new ArgumentNullException("bindingKey");
     }
     else if (bindingKey is IStonBindingName)
     {
         ValidateBindingKey(bindingKey as IStonBindingName);
     }
     else if (bindingKey is IStonBindingIndex)
     {
         ValidateBindingKey(bindingKey as IStonBindingIndex);
     }
     else
     {
         throw new StonImplementationException(bindingKey.GetType(), typeof(IStonBindingKey), typeof(IStonBindingName), typeof(IStonBindingIndex));
     }
 }
示例#4
0
 // writes any binding key
 private void WriteBindingKey(StonTokenWriter writer, IStonBindingKey bindingKey)
 {
     if (bindingKey == null)
     {
         throw new StonException("A non-existing member binding key has been found in the structure to be written.");
     }
     else if (bindingKey is IStonBindingName)
     {
         WriteBindingKey(writer, bindingKey as IStonBindingName);
     }
     else if (bindingKey is IStonBindingIndex)
     {
         WriteBindingKey(writer, bindingKey as IStonBindingIndex);
     }
     else
     {
         throw new StonImplementationException(bindingKey.GetType(), typeof(IStonBindingKey), typeof(IStonBindingName), typeof(IStonBindingIndex));
     }
 }
 /// <summary>
 /// Returns a hash code for a given binding key.
 /// </summary>
 /// <param name="obj">The binding key to get a hash code of.</param>
 /// <returns>The hash code for the binding key.</returns>
 public int GetHashCode(IStonBindingKey obj)
 {
     if (obj == null)
     {
         return(0);
     }
     else if (obj is IStonBindingName)
     {
         return(GetHashCode(obj as IStonBindingName));
     }
     else if (obj is IStonBindingIndex)
     {
         return(GetHashCode(obj as IStonBindingIndex));
     }
     else
     {
         return(0);
     }
 }
 /// <summary>
 /// Determines whether two binding keys are equivalent.
 /// </summary>
 /// <param name="x">The first binding key to compare.</param>
 /// <param name="y">The second binding key to compare.</param>
 /// <returns>True when binding keys are equivalent, false otherwise.</returns>
 public bool Equals(IStonBindingKey x, IStonBindingKey y)
 {
     if (x == y)
     {
         return(true);
     }
     else if (x == null || y == null)
     {
         return(false);
     }
     else if (x is IStonBindingName && y is IStonBindingName)
     {
         return(Equals(x as IStonBindingName, y as IStonBindingName));
     }
     else if (x is IStonBindingIndex && y is IStonBindingIndex)
     {
         return(Equals(x as IStonBindingIndex, y as IStonBindingIndex));
     }
     else
     {
         return(false);
     }
 }
 /// <summary>
 /// Creates a new member path segment, with a given binding key.
 /// </summary>
 /// <param name="bindingKey">The binding key of the member to access.</param>
 /// <returns>The new STON path segment.</returns>
 public IStonMemberPathSegment CreateMemberPathSegment(IStonBindingKey bindingKey)
 => new StonMemberPathSegment(bindingKey);
示例#8
0
 public AMemberSegment(IStonBindingKey bindingKey)
 {
     BindingKey = bindingKey;
 }