Пример #1
0
        /// <summary>
        /// Loads several intermediates from paths on disk using the same definitions.
        /// </summary>
        /// <param name="intermediateFiles">Paths to intermediate files saved on disk.</param>
        /// <param name="creator">ISymbolDefinitionCreator to use when reconstituting the intermediates.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediates</returns>
        public static IEnumerable <Intermediate> Load(IEnumerable <string> intermediateFiles, ISymbolDefinitionCreator creator, bool suppressVersionCheck = false)
        {
            var jsons         = new Queue <JsonWithPath>();
            var intermediates = new List <Intermediate>();

            foreach (var path in intermediateFiles)
            {
                using (var wixout = WixOutput.Read(path))
                {
                    var data = wixout.GetData(WixOutputStreamName);
                    var json = Intermediate.LoadJson(data, wixout.Uri, suppressVersionCheck);

                    Intermediate.LoadDefinitions(json, creator);

                    jsons.Enqueue(new JsonWithPath {
                        Json = json, Path = wixout.Uri
                    });
                }
            }

            while (jsons.Count > 0)
            {
                var jsonWithPath = jsons.Dequeue();

                var intermediate = Intermediate.FinalizeLoad(jsonWithPath.Json, jsonWithPath.Path, creator);

                intermediates.Add(intermediate);
            }

            return(intermediates);
        }
Пример #2
0
 /// <summary>
 /// Loads an intermediate from a stream.
 /// </summary>
 /// <param name="assembly">Assembly with intermediate embedded in resource stream.</param>
 /// <param name="resourceName">Name of resource stream.</param>
 /// <param name="creator">ISymbolDefinitionCreator to use when reconstituting the intermediate.</param>
 /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
 /// <returns>Returns the loaded intermediate.</returns>
 public static Intermediate Load(Assembly assembly, string resourceName, ISymbolDefinitionCreator creator, bool suppressVersionCheck = false)
 {
     using (var wixout = WixOutput.Read(assembly, resourceName))
     {
         return(Intermediate.LoadIntermediate(wixout, creator, suppressVersionCheck));
     }
 }
Пример #3
0
 /// <summary>
 /// Loads an intermediate from a path on disk.
 /// </summary>
 /// <param name="path">Path to intermediate file saved on disk.</param>
 /// <param name="creator">ISymbolDefinitionCreator to use when reconstituting the intermediate.</param>
 /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
 /// <returns>Returns the loaded intermediate.</returns>
 public static Intermediate Load(string path, ISymbolDefinitionCreator creator, bool suppressVersionCheck = false)
 {
     using (var wixout = WixOutput.Read(path))
     {
         return(Intermediate.LoadIntermediate(wixout, creator, suppressVersionCheck));
     }
 }
Пример #4
0
        /// <summary>
        /// Loads an intermediate from a path on disk.
        /// </summary>
        /// <param name="path">Path to intermediate file saved on disk.</param>
        /// <param name="tableDefinitions">Collection containing TableDefinitions to use when reconstituting the intermediate.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediate.</returns>
        public static Intermediate Load(string path, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck)
        {
            using (FileStream stream = File.OpenRead(path))
                using (FileStructure fs = FileStructure.Read(stream))
                {
                    if (FileFormat.Wixobj != fs.FileFormat)
                    {
                        throw new WixUnexpectedFileFormatException(path, FileFormat.Wixobj, fs.FileFormat);
                    }

                    Uri uri = new Uri(Path.GetFullPath(path));
                    using (XmlReader reader = XmlReader.Create(fs.GetDataStream(), null, uri.AbsoluteUri))
                    {
                        try
                        {
                            reader.MoveToContent();
                            return(Intermediate.Read(reader, tableDefinitions, suppressVersionCheck));
                        }
                        catch (XmlException xe)
                        {
                            throw new WixCorruptFileException(path, fs.FileFormat, xe);
                        }
                    }
                }
        }
Пример #5
0
        /// <summary>
        /// Loads several intermediates from paths on disk using the same definitions.
        /// </summary>
        /// <param name="intermediateFiles">Paths to intermediate files saved on disk.</param>
        /// <param name="creator">ITupleDefinitionCreator to use when reconstituting the intermediates.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediates</returns>
        public static IEnumerable <Intermediate> Load(IEnumerable <string> intermediateFiles, ITupleDefinitionCreator creator, bool suppressVersionCheck = false)
        {
            var jsons         = new Queue <JsonWithPath>();
            var intermediates = new List <Intermediate>();

            foreach (var path in intermediateFiles)
            {
                using (var stream = File.OpenRead(path))
                {
                    var uri = new Uri(Path.GetFullPath(path));

                    var json = Intermediate.LoadJson(stream, uri, suppressVersionCheck);

                    Intermediate.LoadDefinitions(json, creator);

                    jsons.Enqueue(new JsonWithPath {
                        Json = json, Path = uri
                    });
                }
            }

            while (jsons.Count > 0)
            {
                var jsonWithPath = jsons.Dequeue();

                var intermediate = Intermediate.FinalizeLoad(jsonWithPath.Json, jsonWithPath.Path, creator);

                intermediates.Add(intermediate);
            }

            return(intermediates);
        }
Пример #6
0
        /// <summary>
        /// Loads an intermediate from a path on disk.
        /// </summary>
        /// <param name="stream">Stream to intermediate file.</param>
        /// <param name="baseUri">Path name of intermediate file.</param>
        /// <param name="creator">ITupleDefinitionCreator to use when reconstituting the intermediate.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediate.</returns>
        private static Intermediate LoadIntermediate(Stream stream, Uri baseUri, ITupleDefinitionCreator creator, bool suppressVersionCheck = false)
        {
            var json = Intermediate.LoadJson(stream, baseUri, suppressVersionCheck);

            Intermediate.LoadDefinitions(json, creator);

            return(Intermediate.FinalizeLoad(json, baseUri, creator));
        }
Пример #7
0
        /// <summary>
        /// Loads an intermediate from a WixOutput.
        /// </summary>
        /// <param name="wixout">Source to load from.</param>
        /// <param name="creator">ISymbolDefinitionCreator to use when reconstituting the intermediate.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediate.</returns>
        private static Intermediate LoadIntermediate(WixOutput wixout, ISymbolDefinitionCreator creator, bool suppressVersionCheck = false)
        {
            var data = wixout.GetData(WixOutputStreamName);
            var json = Intermediate.LoadJson(data, wixout.Uri, suppressVersionCheck);

            Intermediate.LoadDefinitions(json, creator);

            return(Intermediate.FinalizeLoad(json, wixout.Uri, creator));
        }
Пример #8
0
 /// <summary>
 /// Loads an intermediate from a path on disk.
 /// </summary>
 /// <param name="path">Path to intermediate file saved on disk.</param>
 /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
 /// <returns>Returns the loaded intermediate.</returns>
 public static Intermediate Load(string path, bool suppressVersionCheck = false)
 {
     using (var stream = File.OpenRead(path))
     {
         var uri     = new Uri(Path.GetFullPath(path));
         var creator = new SimpleTupleDefinitionCreator();
         return(Intermediate.LoadIntermediate(stream, uri, creator, suppressVersionCheck));
     }
 }
Пример #9
0
        /// <summary>
        /// Loads an intermediate from a stream.
        /// </summary>
        /// <param name="assembly">Assembly with intermediate embedded in resource stream.</param>
        /// <param name="resourceName">Name of resource stream.</param>
        /// <param name="creator">ITupleDefinitionCreator to use when reconstituting the intermediate.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediate.</returns>
        public static Intermediate Load(Assembly assembly, string resourceName, ITupleDefinitionCreator creator, bool suppressVersionCheck = false)
        {
            using (var resourceStream = assembly.GetManifestResourceStream(resourceName))
            {
                var uriBuilder = new UriBuilder(assembly.CodeBase);
                uriBuilder.Scheme   = "embeddedresource";
                uriBuilder.Fragment = resourceName;

                return(Intermediate.LoadIntermediate(resourceStream, uriBuilder.Uri, creator, suppressVersionCheck));
            }
        }
Пример #10
0
        /// <summary>
        /// Loads an intermediate from a stream.
        /// </summary>
        /// <param name="assembly">Assembly with intermediate embedded in resource stream.</param>
        /// <param name="resourceName">Name of resource stream.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediate.</returns>
        public static Intermediate Load(Assembly assembly, string resourceName, bool suppressVersionCheck = false)
        {
            var creator = new SimpleSymbolDefinitionCreator();

            return(Intermediate.Load(assembly, resourceName, creator, suppressVersionCheck));
        }
Пример #11
0
        /// <summary>
        /// Loads an intermediate from a path on disk.
        /// </summary>
        /// <param name="path">Path to intermediate file saved on disk.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediate.</returns>
        public static Intermediate Load(string path, bool suppressVersionCheck = false)
        {
            var creator = new SimpleSymbolDefinitionCreator();

            return(Intermediate.Load(path, creator, suppressVersionCheck));
        }
Пример #12
0
        /// <summary>
        /// Loads several intermediates from paths on disk using the same definitions.
        /// </summary>
        /// <param name="intermediateFiles">Paths to intermediate files saved on disk.</param>
        /// <returns>Returns the loaded intermediates</returns>
        public static IEnumerable <Intermediate> Load(IEnumerable <string> intermediateFiles)
        {
            var creator = new SimpleSymbolDefinitionCreator();

            return(Intermediate.Load(intermediateFiles, creator));
        }
Пример #13
0
 /// <summary>
 /// Loads an intermediate from a WixOutput object.
 /// </summary>
 /// <param name="wixOutput">WixOutput object.</param>
 /// <param name="creator">ISymbolDefinitionCreator to use when reconstituting the intermediate.</param>
 /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
 /// <returns>Returns the loaded intermediate.</returns>
 public static Intermediate Load(WixOutput wixOutput, ISymbolDefinitionCreator creator, bool suppressVersionCheck = false)
 {
     return(Intermediate.LoadIntermediate(wixOutput, creator, suppressVersionCheck));
 }
Пример #14
0
        /// <summary>
        /// Parse an intermediate from an XML format.
        /// </summary>
        /// <param name="reader">XmlReader where the intermediate is persisted.</param>
        /// <param name="tableDefinitions">TableDefinitions to use in the intermediate.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatch.</param>
        /// <returns>The parsed Intermediate.</returns>
        private static Intermediate Read(XmlReader reader, TableDefinitionCollection tableDefinitions, bool suppressVersionCheck)
        {
            if ("wixObject" != reader.LocalName)
            {
                throw new XmlException();
            }

            bool    empty      = reader.IsEmptyElement;
            Version objVersion = null;
            string  id         = null;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "version":
                    objVersion = new Version(reader.Value);
                    break;

                case "id":
                    id = reader.Value;
                    break;
                }
            }

            if (!suppressVersionCheck && null != objVersion && !Intermediate.CurrentVersion.Equals(objVersion))
            {
                throw new WixException(WixDataErrors.VersionMismatch(SourceLineNumber.CreateFromUri(reader.BaseURI), "object", objVersion.ToString(), Intermediate.CurrentVersion.ToString()));
            }

            Intermediate intermediate = new Intermediate();

            intermediate.id = id;

            if (!empty)
            {
                bool done = false;

                while (!done && reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                        case "section":
                            intermediate.AddSection(Section.Read(reader, tableDefinitions));
                            break;

                        default:
                            throw new XmlException();
                        }
                        break;

                    case XmlNodeType.EndElement:
                        done = true;
                        break;
                    }
                }

                if (!done)
                {
                    throw new XmlException();
                }
            }

            return(intermediate);
        }
Пример #15
0
        /// <summary>
        /// Loads several intermediates from paths on disk using the same definitions.
        /// </summary>
        /// <param name="intermediateFiles">Paths to intermediate files saved on disk.</param>
        /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param>
        /// <returns>Returns the loaded intermediates</returns>
        public static IEnumerable <Intermediate> Load(IEnumerable <string> intermediateFiles, bool suppressVersionCheck = false)
        {
            var creator = new SimpleTupleDefinitionCreator();

            return(Intermediate.Load(intermediateFiles, creator));
        }