Example #1
0
        private TM LoadMetadataInternal(string metadataPath)
        {
            var dblMetadata = DblMetadataBase <TL> .Load <TM>(metadataPath, out var exception);

            if (exception != null)
            {
                DblMetadata metadata = XmlSerializationHelper.DeserializeFromFile <DblMetadata>(metadataPath,
                                                                                                out var metadataBaseDeserializationError);
                if (metadataBaseDeserializationError != null)
                {
                    throw new ApplicationException(Localizer.GetString("DblBundle.MetadataInvalid",
                                                                       "Unable to read metadata. File is not a valid Text Release Bundle:") +
                                                   Environment.NewLine + _pathToZippedBundle, metadataBaseDeserializationError);
                }

                throw new ApplicationException(
                          String.Format(Localizer.GetString("DblBundle.MetadataInvalidVersion",
                                                            "Unable to read metadata. Type: {0}. Version: {1}. File is not a valid Text Release Bundle:"),
                                        metadata.Type, metadata.TypeVersion) +
                          Environment.NewLine + _pathToZippedBundle);
            }

            if (!dblMetadata.IsTextReleaseBundle)
            {
                throw new ApplicationException(
                          String.Format(Localizer.GetString("DblBundle.NotTextReleaseBundle",
                                                            "This metadata in this bundle indicates that it is of type \"{0}\". Only Text Release Bundles are currently supported."),
                                        dblMetadata.Type));
            }

            return(dblMetadata);
        }
Example #2
0
        private TM LoadMetadata()
        {
            const string filename     = "metadata.xml";
            string       metadataPath = Path.Combine(m_pathToUnzippedDirectory, filename);

            if (!File.Exists(metadataPath))
            {
                bool sourceBundle = filename.Contains("source") || Directory.Exists(Path.Combine(m_pathToUnzippedDirectory, "gather"));
                if (sourceBundle)
                {
                    throw new ApplicationException(
                              string.Format(LocalizationManager.GetString("DblBundle.SourceReleaseBundle",
                                                                          "This bundle appears to be a source bundle. Only Text Release Bundles are currently supported."), filename) +
                              Environment.NewLine + m_pathToZippedBundle);
                }
                throw new ApplicationException(
                          string.Format(LocalizationManager.GetString("DblBundle.FileMissingFromBundle",
                                                                      "Required {0} file not found. File is not a valid Text Release Bundle:"), filename) +
                          Environment.NewLine + m_pathToZippedBundle);
            }

            Exception exception;
            var       dblMetadata = DblMetadataBase <TL> .Load <TM>(metadataPath, out exception);

            if (exception != null)
            {
                Exception   metadataBaseDeserializationError;
                DblMetadata metadata = XmlSerializationHelper.DeserializeFromFile <DblMetadata>(metadataPath,
                                                                                                out metadataBaseDeserializationError);
                if (metadataBaseDeserializationError != null)
                {
                    throw new ApplicationException(
                              LocalizationManager.GetString("DblBundle.MetadataInvalid",
                                                            "Unable to read metadata. File is not a valid Text Release Bundle:") +
                              Environment.NewLine + m_pathToZippedBundle, metadataBaseDeserializationError);
                }

                throw new ApplicationException(
                          String.Format(LocalizationManager.GetString("DblBundle.MetadataInvalidVersion",
                                                                      "Unable to read metadata. Type: {0}. Version: {1}. File is not a valid Text Release Bundle:"),
                                        metadata.Type, metadata.TypeVersion) +
                          Environment.NewLine + m_pathToZippedBundle);
            }

            if (!dblMetadata.IsTextReleaseBundle)
            {
                throw new ApplicationException(
                          String.Format(LocalizationManager.GetString("DblBundle.NotTextReleaseBundle",
                                                                      "This metadata in this bundle indicates that it is of type \"{0}\". Only Text Release Bundles are currently supported."),
                                        dblMetadata.Type));
            }

            return(dblMetadata);
        }