Пример #1
0
        private string GetOutboundUrl(FzFile file)
        {
            var flatFileContents = file.Content.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
            var startOfUrl       = flatFileContents.IndexOf("getRelativeUrl(){return\"");
            var endOfUrl         = flatFileContents.Substring(startOfUrl + 24).IndexOf("\"");

            return(flatFileContents.Substring(startOfUrl + 24, endOfUrl));
        }
Пример #2
0
        public static FzFileAndComponents ExtractBeanResource(string componentName, FzFile file)
        {
            var beanMethodMatch = Regex.Match(file.Content, @"@Bean(\s+)public (\S+) " + componentName + @"\(\)(\s+){(\s+)return new (\S+)\((.*)");

            if (!beanMethodMatch.Success)
            {
                return(null);
            }

            // Get all resources
            var beanResourceNamesAndVariableNames = new Dictionary <string, string>();
            var beanResourceMatches = Regex.Matches(file.Content, @"@Resource(.*)(\s+)(.*)");

            foreach (Match match in beanResourceMatches)
            {
                var resourceName     = Regex.Match(match.Value, @"""(\w+)""");
                var resourceVariable = Regex.Match(match.Value, @"(\w+);");

                beanResourceNamesAndVariableNames.Add(resourceName.Value, resourceVariable.Value.Substring(0, resourceVariable.Value.Length - 1));
            }

            // See if a resource matches from the method match
            foreach (var resourceAndVariableName in beanResourceNamesAndVariableNames)
            {
                if (beanMethodMatch.Value.Contains(resourceAndVariableName.Value))
                {
                    var newFileAndComponent = new FzFileAndComponents {
                        File = file
                    };
                    newFileAndComponent.ComponentNames.Add(resourceAndVariableName.Key);
                    return(newFileAndComponent);
                }
            }

            return(null);
        }