// writes any initial context private void WriteInitialContext(StonTokenWriter writer, IStonInitialContext context) { if (context is IStonAncestorInitialContext) { WriteInitialContext(writer, context as IStonAncestorInitialContext); } else if (context is IStonGlobalEntityInitialContext) { WriteInitialContext(writer, context as IStonGlobalEntityInitialContext); } else { throw new StonImplementationException(context.GetType(), typeof(IStonInitialContext), typeof(IStonAncestorInitialContext), typeof(IStonGlobalEntityInitialContext)); } }
/// <summary> /// Creates a structurally equivalent initial context from a given context. /// </summary> /// <param name="context">The context to copy the structure of.</param> /// <returns>A structurally equivalent copy of the given context.</returns> public static IStonInitialContext Copy(IStonInitialContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (context is IStonAncestorInitialContext) { return(StonAncestorInitialContext.Copy(context as IStonAncestorInitialContext)); } if (context is IStonGlobalEntityInitialContext) { return(StonGlobalEntityInitialContext.Copy(context as IStonGlobalEntityInitialContext)); } throw new StonImplementationException(context.GetType(), typeof(IStonInitialContext), typeof(IStonAncestorInitialContext), typeof(IStonGlobalEntityInitialContext)); }
/// <summary> /// Checks the validity of a given STON initial context. /// </summary> /// <param name="initialContext">The initial context to check the validity of.</param> public static void ValidateInitialContext(IStonInitialContext initialContext) { if (initialContext == null) { throw new ArgumentNullException("initialContext"); } else if (initialContext is IStonAncestorInitialContext) { ValidateInitialContext(initialContext as IStonAncestorInitialContext); } else if (initialContext is IStonGlobalEntityInitialContext) { ValidateInitialContext(initialContext as IStonGlobalEntityInitialContext); } else { throw new StonImplementationException(initialContext.GetType(), typeof(IStonInitialContext), typeof(IStonAncestorInitialContext), typeof(IStonGlobalEntityInitialContext)); } }