/// <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)); }
/// <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)); } }
// 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)); } }