예제 #1
0
        internal static string[] GetClickOnceInfo(ref string manifestPath, bool scanRemote, ref bool isUncPath, ref bool isHttpPath)
        {
            string[]    strArray  = new string[2];
            string      str1      = string.Empty;
            string      baseDir   = string.Empty;
            string      str2      = string.Empty;
            XmlDocument deployDoc = new XmlDocument();

            if (manifestPath == null || manifestPath.Length == 0)
            {
                throw new ArgumentException(Resources.EMPTY_MANIFESTPATH);
            }
            try
            {
                Uri  uri = new Uri(manifestPath);
                bool flag;
                if (uri.IsLoopback)
                {
                    flag = ManifestReader.GetManifestFromLocalPath(deployDoc, ref manifestPath, out baseDir);
                }
                else if (uri.IsUnc)
                {
                    isUncPath = true;
                    flag      = scanRemote && ManifestReader.GetManifestFromUncPath(deployDoc, ref manifestPath, out baseDir);
                }
                else if (uri.Host != null && uri.Host.Length > 0)
                {
                    isHttpPath = true;
                    flag       = scanRemote && ManifestReader.GetManifestFromHttpUrlPath(manifestPath, deployDoc, out baseDir);
                }
                else
                {
                    flag = false;
                }
                if (flag)
                {
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(deployDoc.NameTable);
                    nsmgr.AddNamespace("asmv1", "urn:schemas-microsoft-com:asm.v1");
                    nsmgr.AddNamespace("def", "urn:schemas-microsoft-com:asm.v2");
                    XmlNode xmlNode1 = (XmlNode)deployDoc.DocumentElement;
                    XmlNode xmlNode2 = xmlNode1.SelectSingleNode("/asmv1:assembly/def:dependency/def:dependentAssembly", nsmgr);
                    XmlNode xmlNode3 = xmlNode1.SelectSingleNode("/asmv1:assembly/def:dependency/def:dependentAssembly/def:assemblyIdentity", nsmgr);
                    string  path2_1  = xmlNode2.Attributes["codebase"].Value;
                    string  path2_2  = xmlNode3.Attributes["name"].Value;
                    str2 = xmlNode3.Attributes["version"].Value;
                    if (isHttpPath)
                    {
                        string str3 = (baseDir + path2_1).Replace("\\", "/");
                        str1 = str3.Substring(0, str3.LastIndexOf(".manifest")) + ".deploy";
                    }
                    else
                    {
                        str1 = Path.Combine(Path.GetDirectoryName(Path.Combine(baseDir, path2_1)), path2_2) + ".deploy";
                    }
                }
                else
                {
                    str1 = (string)null;
                    str2 = (string)null;
                }
            }
            catch (Exception ex)
            {
                Globals.AddException(ex);
            }
            strArray[0] = str1;
            strArray[1] = str2;
            return(strArray);
        }