コード例 #1
0
        public static ClickOnceManifest Parse(XElement xml, Uri applicationBaseUri = null)
        {
            ClickOnceManifest manifest = new ClickOnceManifest {
                ApplicationBaseUri = applicationBaseUri
            };
            XElement xelement =
                xml.Elements(XName.Get("entryPoint", "urn:schemas-microsoft-com:asm.v2")).First().
                Elements(XName.Get("commandLine", "urn:schemas-microsoft-com:asm.v2")).First();

            manifest.CommandLine = xelement.Attribute(XName.Get("file")).Value;
            manifest.Parameters  = xelement.Attribute(XName.Get("parameters")).Value;
            manifest.Files       =
                xml.Elements(XName.Get("dependency", "urn:schemas-microsoft-com:asm.v2"))
                .SelectMany((Func <XElement, IEnumerable <XElement> >)
                                (dependency =>
                                dependency.Elements(XName.Get("dependentAssembly", "urn:schemas-microsoft-com:asm.v2"))))
                .Select((Func <XElement, XAttribute>)(depAssem => depAssem.Attribute(XName.Get("codebase"))))
                .Where(attr => attr != null)
                .Select((Func <XAttribute, string>)(attr => attr.Value))
                .Concat(
                    xml.Elements(XName.Get("file", "urn:schemas-microsoft-com:asm.v2"))
                    .Select(file => file.Attribute(XName.Get("name")).Value)
                    )
                .ToArray();
            return(manifest);
        }
コード例 #2
0
        ClickOnceManifest LoadManifest(XElement applicationManifestXml, Uri absoluteCodebase)
        {
            ClickOnceManifest manifest = ManifestParser.DownloadAndParseManifest(absoluteCodebase);

            manifest.Version   = ParseVersion(applicationManifestXml);
            manifest.LocalPath = GetVersionPath(manifest.Version);
            return(manifest);
        }
コード例 #3
0
        public void Download()
        {
            var applicationManifestXml = XElement.Load(ApplicationUrl);
            var absoluteCodebase       =
                new Uri(ManifestParser.GetUriWithoutFile(ApplicationUrl),
                        ParseCodebase(applicationManifestXml));

            ApplicationManifest = LoadManifest(applicationManifestXml, absoluteCodebase);
            DownloadFiles(ApplicationManifest);
        }
コード例 #4
0
 static void DownloadFiles(ClickOnceManifest manifest)
 {
     if (!Directory.Exists(manifest.LocalPath))
     Directory.CreateDirectory(manifest.LocalPath);
      WebClient webClient = new WebClient();
      foreach (string path2 in manifest.Files)
      {
     Uri address = new Uri(manifest.ApplicationBaseUri, path2.Replace('\\', '/') + ".deploy");
     string str = Path.Combine(manifest.LocalPath, path2);
     string path = Regex.Replace(str, "(?<!:)\\\\[^\\\\]+$", "");
     if (!Directory.Exists(path))
        Directory.CreateDirectory(path);
     if (!File.Exists(str))
        webClient.DownloadFile(address, str);
      }
 }
コード例 #5
0
        public static void Start(this ClickOnceManifest manifest, string[] args)
        {
            string  fileName  = Path.Combine(manifest.LocalPath, manifest.CommandLine);
            string  arguments = string.Join(" ", args.Select(s => '"' + s + '"').ToArray());
            Process process   =
                new Process()
            {
                StartInfo           = CreateProcessStartInfo(fileName, arguments, manifest.LocalPath),
                EnableRaisingEvents = true
            };

            process.OutputDataReceived += (DataReceivedEventHandler)((s, dea) => Console.Error.WriteLine(dea.Data));
            process.ErrorDataReceived  += (DataReceivedEventHandler)((s, dea) => Console.WriteLine(dea.Data));
            Console.WriteLine("Starting app: " + fileName);
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            Console.WriteLine("Started");
            process.WaitForExit();
        }
コード例 #6
0
        static void DownloadFiles(ClickOnceManifest manifest)
        {
            if (!Directory.Exists(manifest.LocalPath))
            {
                Directory.CreateDirectory(manifest.LocalPath);
            }
            WebClient webClient = new WebClient();

            foreach (string path2 in manifest.Files)
            {
                Uri    address = new Uri(manifest.ApplicationBaseUri, path2.Replace('\\', '/') + ".deploy");
                string str     = Path.Combine(manifest.LocalPath, path2);
                string path    = Regex.Replace(str, "(?<!:)\\\\[^\\\\]+$", "");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (!File.Exists(str))
                {
                    webClient.DownloadFile(address, str);
                }
            }
        }
コード例 #7
0
 public static ClickOnceManifest Parse(XElement xml, Uri applicationBaseUri = null)
 {
     ClickOnceManifest manifest = new ClickOnceManifest { ApplicationBaseUri = applicationBaseUri };
      XElement xelement =
     xml.Elements(XName.Get("entryPoint", "urn:schemas-microsoft-com:asm.v2")).First().
        Elements(XName.Get("commandLine", "urn:schemas-microsoft-com:asm.v2")).First();
      manifest.CommandLine = xelement.Attribute(XName.Get("file")).Value;
      manifest.Parameters = xelement.Attribute(XName.Get("parameters")).Value;
      manifest.Files =
     xml.Elements(XName.Get("dependency", "urn:schemas-microsoft-com:asm.v2"))
        .SelectMany((Func<XElement, IEnumerable<XElement>>)
                    (dependency =>
                     dependency.Elements(XName.Get("dependentAssembly", "urn:schemas-microsoft-com:asm.v2"))))
        .Select((Func<XElement, XAttribute>)(depAssem => depAssem.Attribute(XName.Get("codebase"))))
        .Where(attr => attr != null)
        .Select((Func<XAttribute, string>)(attr => attr.Value))
     .Concat(
        xml.Elements(XName.Get("file", "urn:schemas-microsoft-com:asm.v2"))
           .Select(file => file.Attribute(XName.Get("name")).Value)
        )
     .ToArray();
      return manifest;
 }