void ValidatePackage() { PackageDetails details = store.LoadPackageFromStore(Location); if (details != null) { Warnings = details.Warnings; Id = details.PackageId; } else { PackageValidatorSettings settings = new PackageValidatorSettings(ValidationBehavior.LogWarning, ValidationBehavior.None, ValidationBehavior.Enforce, ValidationBehavior.LogWarning); ValidationResults log = PackageValidator.Validate(reader, settings); if (log.HasErrors) { // Shouldn't have any since enforcing errors. throw new SafeToDisplayException(log, culture.Format(culture.Resources.PackageNotValid, string.Empty)); } else if (log.HasWarnings) { using (System.Xml.XmlReader xmlLog = log.ToXml()) { Warnings = LearningStoreXml.CreateAndLoad(xmlLog); } } } }
/// <summary> /// Converts a value returned from a LearningStore query to a <c>LearningStoreXml</c>. /// Throws an exception if the value is <c>DBNull</c>. /// </summary> /// /// <param name="value">A value from a <c>DataRow</c> within a <c>DataTable</c> /// returned from a LearningStore query.</param> /// /// <param name="result">Where to store the result.</param> /// public static void CastNonNull(object value, out LearningStoreXml result) { if (value is DBNull) { throw new ArgumentException("Unexpected DBNull value"); } else { result = (LearningStoreXml)value; } }