/// <summary> /// Parses the root scene of the .X file /// </summary> /// <param name="data"></param> private IEnumerable<Part> ExtractRootParts(string data) { return XDataObjectFactory.ExtractDataObjects(ref data) .Where(obj => obj.IsVisualObject) .Select(obj => PartFromDataObject(obj)) .ToList(); }
/// <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. /// </summary> /// <param name="type">The template name of the type of the data object</param> /// <param name="name">The name of the data object</param> /// <param name="body">The remaining unparsed body text of the data object</param> /// <param name="factory">The factory used to create this object</param> /// <exception cref="ArgumentNullException">Thrown if the <paramref name="type"/> or <paramref name="factory"/> arguments are null.</exception> /// <remarks>The factory passed in is used to further parse the object's body text, including /// resolving references to previously defined objects and templates.</remarks> public XDataObject(string type, string name, string body, XDataObjectFactory factory) { if (type == null) { throw new ArgumentNullException("type"); } if (factory == null) { throw new ArgumentNullException("factory"); } DataObjectType = type; Name = name; Children = factory.ExtractDataObjectsImpl(ref body); Body = body; }
/// <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; }