Example #1
0
        public void ParseBody()
        {
            FilesToBeDownloaded.Clear();

            bool insideFileParsing =
                false;

            using (System.IO.StringReader bodyReader =
                       new System.IO.StringReader(m_srcSrvBody))
            {
                string currentLine =
                    bodyReader.ReadLine();
                while ((currentLine = bodyReader.ReadLine()) != null)
                {
                    if (currentLine == FileListBegin)
                    {
                        insideFileParsing = true;
                        currentLine       = bodyReader.ReadLine();
                        m_targetPath     +=
                            m_http_alias.Replace("http://ReferenceSource.microsoft.com/", string.Empty).Replace("/", "\\");
                        m_targetPath = Utility.CleanupPath(m_targetPath);
                    }
                    else if (currentLine == FileListEnd)
                    {
                        insideFileParsing = false;
                    }

                    if (String.IsNullOrEmpty(currentLine))
                    {
                        continue;
                    }

                    if (insideFileParsing)
                    {
                        SrcSrvDownloadAbleFile file = BuildSrcSrvDownloadFromFile(m_targetPath, currentLine);
                        if (null != file)
                        {
                            FilesToBeDownloaded.Add(file);
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(currentLine) &&
                            !currentLine.StartsWith("SRCSRV"))
                        {
                            string[] parameters =
                                currentLine.Split('=');
                            if (parameters.Length == 2)
                            {
                                try
                                {
                                    if (null != m_tempTable[parameters[0]])
                                    {
                                        ((PropertyInfo)m_tempTable[parameters[0]]).SetValue(this, parameters[1], null);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Debug.WriteLine(ex.Message);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        BuildSrcSrvDownloadFromFile(string targetPath, string srcsrvFile)
        {
            String[] rawData = srcsrvFile.Split(new Char[] { '*' });
            if (rawData.Length != 4)
            {
                return(null);
            }

            // With VS 2008 SP1, some of the files on the reference symbol
            // server don't have the HTTP_ALIAS value set.
            if (null == Http_extract_target)
            {
                return(null);
            }

            string tempTarget =
                Http_extract_target;

            tempTarget =
                tempTarget.Replace("%HTTP_ALIAS%", Http_Alias);

            int fnFileIndex = 0;

            while ((fnFileIndex = tempTarget.IndexOf("%fnfile%")) > 0)
            {
                Match tempMatch = fnfileCleaner.Match(tempTarget);
                //tempMatch.Value;
                if (tempMatch.Success)
                {
                    int fileNumber =
                        Convert.ToInt32(tempMatch.Groups["filenumber"].Value) - 1;

                    tempTarget =
                        tempTarget.Replace(tempMatch.Value, System.IO.Path.GetFileName(rawData[fileNumber]));
                }
            }

            for (int i = 0; i < rawData.Length; i++)
            {
                tempTarget =
                    tempTarget.Replace(String.Format("%var{0}%", i + 1), rawData[i]);
            }
            // Build up the output directory.
            StringBuilder targetKey = new StringBuilder();

            targetKey.Append(Utility.CleanupPath(targetPath));
            targetKey.Append(Utility.CleanupPath(rawData[SrcSrvIndex]));
            targetKey.Append(Utility.CleanupPath(rawData[SymbolIndex].
                                                 Replace('/', '\\')));
            targetKey.Append(Utility.CleanupPath(rawData[VersionIndex]));
            targetKey.Append(Path.GetFileName(rawData[BuildIndex]));

            SrcSrvDownloadAbleFile tempFile =
                new SrcSrvDownloadAbleFile();

            tempFile.LocalFileTarget = targetKey.ToString();

            tempFile.LocalFileTargetAlternative =
                Utility.CleanupPath(targetPath) + Utility.PreparePath(rawData[0]);
            tempFile.UrlToBeRequested = tempTarget;

            return(tempFile);
        }