Пример #1
0
 /// <summary>
 /// Deserialize a stream reader into a Manifest object.
 /// </summary>
 /// <param name="filePath">file path.</param>
 /// <returns>Manifest object populated and validated.</returns>
 public static MinManifestInfo CreateManifestInfoFromPath(string filePath)
 {
     using (StreamReader streamReader = new StreamReader(filePath))
     {
         return(MinManifestInfo.CreateManifestInfoFromStreamReader(streamReader));
     }
 }
Пример #2
0
 /// <summary>
 /// Deserialize a stream into a Manifest object.
 /// </summary>
 /// <param name="stream">Manifest stream.</param>
 /// <returns>Manifest object populated and validated.</returns>
 public static MinManifestInfo CreateManifestInfoFromStream(Stream stream)
 {
     using (StreamReader streamReader = new StreamReader(stream))
     {
         return(MinManifestInfo.CreateManifestInfoFromStreamReader(streamReader));
     }
 }
Пример #3
0
        /// <summary>
        /// Validate manifest info integrity.
        /// </summary>
        private static void ValidateManifestInfo(MinManifestInfo manifestInfo)
        {
            if (manifestInfo == null)
            {
                throw new InvalidDataException(ValidationErrorFailedManifestCreation);
            }

            if (string.IsNullOrEmpty(manifestInfo.Id))
            {
                throw new InvalidDataException(ValidationErrorMissingField + "PackageIdentifier");
            }

            if (string.IsNullOrEmpty(manifestInfo.Version))
            {
                throw new InvalidDataException(ValidationErrorMissingField + "PackageVersion");
            }

            if (string.IsNullOrEmpty(manifestInfo.ManifestType))
            {
                throw new InvalidDataException(ValidationErrorMissingField + "ManifestType");
            }

            if (string.IsNullOrEmpty(manifestInfo.ManifestVersion))
            {
                throw new InvalidDataException(ValidationErrorMissingField + "ManifestVersion");
            }

            if (string.IsNullOrEmpty(manifestInfo.PackageLocale) &&
                (manifestInfo.ManifestType == ManifestTypeDefaultLocale ||
                 manifestInfo.ManifestType == ManifestTypeLocale ||
                 manifestInfo.ManifestType == ManifestTypeSingleton))
            {
                throw new InvalidDataException(ValidationErrorMissingField + "PackageLocale");
            }
        }