Пример #1
0
        public void ParseFileContentWpf(CsprojWpfFile csProjWpfFile, string fileContent)
        {
            string regex = "<Page\\s+Include\\s*=\\s*\"(.+)?\">";

            foreach (Match match in Regex.Matches(fileContent, regex))
            {
                int    s = match.Groups.Count;
                string windowRelative = match.Groups[s - 1].Value;
                logger.Debug("windowRelative: " + windowRelative);
                string windowStr = windowRelative.Contains("\\") ?
                                   windowRelative.Substring(windowRelative.LastIndexOf("\\") + 1) : windowRelative;
                string regex2 = "<Compile\\s+Include\\s*=\\s*\"(.+)?\">\\s*\n+" +
                                "\\s*<DependentUpon>" + windowStr + "</DependentUpon>";
                MatchCollection matchCollection = Regex.Matches(fileContent, regex2);
                if (matchCollection.Count == 0)
                {
                    logger.Error("Found Page, but not found corresponding .cs file: " + windowRelative);
                    continue;
                }
                string relativeCsFile = matchCollection[0].Groups[1].Value;
                if (csProjWpfFile.MapXamlCsFilesPath == null)
                {
                    csProjWpfFile.MapXamlCsFilesPath = new Dictionary <string, string>();
                }
                csProjWpfFile.MapXamlCsFilesPath.Add(
                    Path.Combine(Directory.GetParent(csProjWpfFile.Path).FullName, windowRelative),
                    Path.Combine(Directory.GetParent(csProjWpfFile.Path).FullName, relativeCsFile));
            }
            //string relativePath = FindApplicationDefinition(fileContent);
            //csProjWpfFile.ApplicationDefinion =
            //Path.Combine(Directory.GetParent(csProjWpfFile.Path).FullName, relativePath);
        }
Пример #2
0
        public CsprojFile ParseFileContent(string filePath)
        {
            string        fileContent      = Utils.ReadFileContent(filePath);
            CsprojFile    re               = null;
            List <String> projectTypeGuids = FindProjectTypeGuids(fileContent);

            if (projectTypeGuids != null && projectTypeGuids.Contains(CsprojFile.WPF_PROJECT_TYPE_GUID))
            {
                re = new CsprojWpfFile(filePath);
                ((CsprojWpfFile)re).ProjectTypeGuids = projectTypeGuids;
                //ParseFileContentWpf((CsprojWpfFile)re, fileContent);
            }
            else
            {
                re = new CsprojWfaFile(filePath);
                //ParseFileContentWfa((CsprojWfaFile)re, fileContent);
            }
            return(re);
        }