packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/UtilitiesLibrary/MeshLoader/XMeshLoader.cs
/// <summary>
/// Validates the header of the .X file. Enforces the text-only requirement of this code.
/// </summary>
/// <param name="xFile"></param>
Validates the header of the .X file. Enforces the text-only requirement of this code.
Validates the header of the . X file . Enforces the text - only requirement of this code .
private void ValidateHeader(string fileHeader)
        {
            Regex headerParse = new Regex(@"xof (?<vermajor>\d\d)(?<verminor>\d\d)(?<format>\w\w\w[\w\s])(?<floatsize>\d\d\d\d)");
            Match m = headerParse.Match(fileHeader);
            if (!m.Success)
            {
                throw new System.IO.InvalidDataException("Invalid .X file.");
            }
            if (m.Groups.Count != 5)
            {
                throw new System.IO.InvalidDataException("Invalid .X file.");
            }
            if (m.Groups["vermajor"].ToString() != "03")                     
                throw new System.IO.InvalidDataException("Unknown .X file version.");
            if (m.Groups["format"].ToString() != "txt ")
                throw new System.IO.InvalidDataException("Only text .X files are supported.");
        }
private void ValidateHeader ( string fileHeader ) { Regex headerParse = new Regex ( @"xof (?<vermajor>\d\d)(?<verminor>\d\d)(?<format>\w\w\w[\w\s])(?<floatsize>\d\d\d\d)" ) ; Match m = headerParse . Match ( fileHeader ) ; if ( ! m . Success ) { throw new System . IO . InvalidDataException ( " " ) ; } if ( m . Groups . Count != 5 ) { throw new System . IO . InvalidDataException ( " " ) ; } if ( m . Groups [ " " ] . ToString ( ) != " " ) throw new System . IO . InvalidDataException ( " " ) ; if ( m . Groups [ " " ] . ToString ( ) != " " ) throw new System . IO . InvalidDataException ( " " ) ; }
Validates the header of the .X file.
Validates the header of the . X file .
// None of the capture groups are optional, so a successful match // should always have 5 capture groups // version 3.x supported
fileHeader
string
xFile
None