コード例 #1
0
        public void ValidateFormats(FileFormatVersions version)
        {
            byte[] Roundtrip()
            {
                var data = SdbSchemaData.GetSchemaData(version);

                using (var ms = new MemoryStream())
                {
                    data.SerializeSdbData(ms);
                    return(ms.ToArray());
                }
            }

            byte[] GetStream()
            {
                using (var stream = SdbSchemaData.GetStream(version, SdbSchemaData.Constraints))
                    using (var ms = new MemoryStream())
                    {
                        stream.CopyTo(ms);
                        return(ms.ToArray());
                    }
            }

            var expected = GetStream();
            var actual   = Roundtrip();

            Assert.Equal(expected.Length, actual.Length);
            Assert.Equal(expected, actual);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the SchemaValidator.
 /// </summary>
 /// <param name="fileFormat">The target Open XML format.</param>
 /// <exception cref="ArgumentOutOfRangeException">Thrown when the "fileFormat" parameter is not FileFormat.Office2007, FileFormat.Office2010 or FileFormat.O15.</exception>
 public SchemaValidator(FileFormatVersions fileFormat)
 {
     _sdbSchemaDatas      = SdbSchemaData.GetSchemaData(fileFormat);
     _schemaTypeValidator = new SchemaTypeValidator(_sdbSchemaDatas);
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the SchemaTypeValidator.
 /// </summary>
 /// <param name="sdbSchemaDatas"></param>
 internal SchemaTypeValidator(SdbSchemaData sdbSchemaDatas)
 {
     _sdbSchemaDatas = sdbSchemaDatas;
 }