public static Manifest ReadFrom(Stream stream, IPropertyProvider propertyProvider)
{
XDocument document;
if (propertyProvider == NullPropertyProvider.Instance)
{
document = XDocument.Load(stream);
}
else
{
string content = Preprocessor.Process(stream, propertyProvider);
document = XDocument.Parse(content);
}
string schemaNamespace = GetSchemaNamespace(document);
foreach (var e in document.Descendants())
{
// Assign the schema namespace derived to all nodes in the document.
e.Name = XName.Get(e.Name.LocalName, schemaNamespace);
}
// Validate the schema
ValidateManifestSchema(document, schemaNamespace);
// Serialize it
var manifest = ManifestReader.ReadManifest(document);
// Validate before returning
Validate(manifest);
return(manifest);
}