packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/UtilitiesLibrary/MeshLoader/XMeshLoader.XDataObject.cs
/// <summary>
/// Creates an <see cref="XTemplateObject" /> for the given "template" data object
/// type. Parses the UUID, and also the restriction list from the body, matching
/// restriction references to known template objects when possible.
/// </summary>
/// <param name="name">The name of the template</param>
/// <param name="body">The remaining unparsed body text for the template</param>
/// <param name="uuid">Receives the declared UUID for the new template object</param>
/// <returns>A new <see cref="XTemplateObject"/> instance</returns>
Creates an  for the given "template" data object
type. Parses the UUID, and also the restriction list from the body, matching
restriction references to known template objects when possible.
Creates an for the given " template " data object type . Parses the UUID and also the restriction list from the body matching restriction references to known template objects when possible .
private XTemplateObject CreateTemplateObject(string name, ref string body, out string uuid)
            {
                IEnumerable<IEnumerable<IXTemplateObject>> restrictEnums =
                    ExtractByRegex<IEnumerable<IXTemplateObject>>(
                        ref body, restrictionsDeclarationRegex, ExtractRestriction);
                List<IXTemplateObject> restrictList = new List<IXTemplateObject>();
                bool isOpen = false;
                foreach (IEnumerable<IXTemplateObject> restrictEnum in restrictEnums)
                {
                    foreach (IXTemplateObject restrictObject in restrictEnum)
                    {
                        if (restrictObject == null)
                        {
                            isOpen = true;
                        }
                        else if (!isOpen)
                        {
                            restrictList.Add(restrictObject);
                        }
                        else
                        {
                            throw new InvalidDataException(
                                string.Format(CultureInfo.InvariantCulture,
                                "Template \"{0}\" mixes open restriction with non-open.",
                                name));
                        }
                    }
                }
                uuid = ExtractUuid(ref body);
                return restrictList.Count > 0 ?
                    new XTemplateObject(name, body, this, restrictList) :
                    new XTemplateObject(name, body, this,
                        isOpen ? TemplateRestriction.Open : TemplateRestriction.Closed);
            }
private XTemplateObject CreateTemplateObject ( string name , ref string body , out string uuid ) { IEnumerable < IEnumerable < IXTemplateObject > > restrictEnums = ExtractByRegex < IEnumerable < IXTemplateObject > > ( ref body , restrictionsDeclarationRegex , ExtractRestriction ) ; List < IXTemplateObject > restrictList = new List < IXTemplateObject > ( ) ; bool isOpen = false ; foreach ( IEnumerable < IXTemplateObject > restrictEnum in restrictEnums ) { foreach ( IXTemplateObject restrictObject in restrictEnum ) { if ( restrictObject == null ) { isOpen = true ; } else if ( ! isOpen ) { restrictList . Add ( restrictObject ) ; } else { throw new InvalidDataException ( string . Format ( CultureInfo . InvariantCulture , " \" \" " , name ) ) ; } } } uuid = ExtractUuid ( ref body ) ; return restrictList . Count > 0 ? new XTemplateObject ( name , body , this , restrictList ) : new XTemplateObject ( name , body , this , isOpen ? TemplateRestriction . Open : TemplateRestriction . Closed ) ; }
Creates an  for the given "template" data object
type.
Creates an for the given " template " data object type .
A new  instance
A new instance
name
string
The name of the template
The name of the template
string
out
body
The remaining unparsed body text for the template
The remaining unparsed body text for the template
uuid
Receives the declared UUID for the new template object
Receives the declared UUID for the new template object