/// <summary> /// Constructor for template objects having the <see cref="TemplateRestriction.Open" /> or <see cref="TemplateRestriction.Closed" /> restriction. /// </summary> /// <param name="name">The name of the template object</param> /// <param name="body">The remaining unparsed body of the template object</param> /// <param name="factory">The factory used to create this object</param> /// <param name="restricted">The type of restriction of the template object</param> /// <exception cref="ArgumentException">Thrown if the restriction given is not either <see cref="TemplateRestriction.Open" /> or <see cref="TemplateRestriction.Closed" />.</exception> /// <seealso cref="XDataObject.XDataObject"/> public XTemplateObject(string name, string body, XDataObjectFactory factory, TemplateRestriction restricted) : base("template", name, body, factory) { if (restricted == TemplateRestriction.Restricted) { throw new ArgumentException("A restricted template must have actual restrictions. Without any, the restricted state may be only 'Open' or 'Closed'"); } Restrictions = null; Restricted = restricted; }
/// <summary> /// Constructor for template objects having the <see cref="TemplateRestriction.Restricted" /> restriction. /// </summary> /// <param name="name">The name of the template object</param> /// <param name="body">The remaining unparsed body of the template object</param> /// <param name="factory">The factory used to create this object</param> /// <param name="restrictions">A list of template objects representing the only valid types of data object children for this type</param> /// <seealso cref="XDataObject.XDataObject"/> public XTemplateObject(string name, string body, XDataObjectFactory factory, IList <IXTemplateObject> restrictions) : base("template", name, body, factory) { Restrictions = new ReadOnlyCollection <IXTemplateObject>(restrictions); Restricted = TemplateRestriction.Restricted; }