Exemplo n.º 1
0
        private void DoParse(string layoutFilePath, LayoutFileParseResult result)
        {
            var index = 0;
            string masterFilePath = null;

            var fileContent = ReadFileContent(layoutFilePath).Trim();
            fileContent = _commentRegex.Replace(fileContent, String.Empty);
            fileContent = _codeRegex.Replace(fileContent, String.Empty);

            while (index < fileContent.Length)
            {
                if (String.IsNullOrEmpty(masterFilePath))
                {
                    index = ParseMasterReference(fileContent, index, out masterFilePath);

                    if (!String.IsNullOrEmpty(masterFilePath))
                    {
                        masterFilePath = FileReferencingUtil.GetReferencedFilePhysicalPath(layoutFilePath, masterFilePath, ApplicationBasePath);
                        result.MasterFilePaths.Add(masterFilePath);
                    }
                }

                // find zones
                var m = _startTagRegex.Match(fileContent, index);

                if (m.Success)
                {
                    index = m.Index + m.Length;

                    var tagName = m.Groups["tagname"].Value;

                    if (!String.IsNullOrEmpty(tagName) && tagName.IgnoreCaseEquals("sig:ZoneControl"))
                    {
                        var attrNameGroup = m.Groups["attrname"];
                        var hasRunAtServer = false;
                        string zoneName = null;

                        for (var i = 0; i < attrNameGroup.Captures.Count; i++)
                        {
                            if (attrNameGroup.Captures[i].Value.IgnoreCaseEquals("runat"))
                            {
                                hasRunAtServer = m.Groups["attrval"].Captures[i].Value.IgnoreCaseEquals("server");
                            }
                            else if (attrNameGroup.Captures[i].Value.IgnoreCaseEquals("ZoneName"))
                            {
                                zoneName = m.Groups["attrval"].Captures[i].Value;
                                if (hasRunAtServer) break;
                            }
                        }

                        if (hasRunAtServer)
                        {
                            result.ZoneNames.Add(zoneName);
                        }
                    }

                    continue;
                }

                m = _endTagRegex.Match(fileContent, index);

                if (m.Success)
                {
                    index = m.Index + m.Length;
                    continue;
                }

                ++index;
            }

            if (!String.IsNullOrEmpty(masterFilePath))
            {
                DoParse(masterFilePath, result);
            }
        }
Exemplo n.º 2
0
 public LayoutFileParseResult Parse(string layoutFilePath)
 {
     var result = new LayoutFileParseResult();
     DoParse(layoutFilePath, result);
     return result;
 }