コード例 #1
0
ファイル: Search.aspx.cs プロジェクト: MikeKMiller/weavver
//-------------------------------------------------------------------------------------------
    protected void Submit_Click(object sender, EventArgs e)
    {
        if (SearchBox.Text == "")
        {
            return;
        }

        using (WeavverEntityContainer data = new WeavverEntityContainer())
        {
            var results = data.SearchAllTables(SearchBox.Text);

            var foundTypes = (results.GroupBy(l => l.TableName)
                              .Select(g => new
            {
                Type = CleanUp(g.Key),
                Count = g.Distinct().Count()
            })).OrderByDescending(g => g.Count);

            FoundTypes.DataSource = foundTypes;
            FoundTypes.DataBind();

            var results2      = data.SearchAllTables(SearchBox.Text);
            var searchResults = (results2
                                 .Select(g => new { TableName = CleanUp(g.TableName),
                                                    ColumnName = CleanUp(g.ColumnName),
                                                    ColumnValue = Trim(g.ColumnValue) }));


            List.DataSource = searchResults;
            List.DataBind();
        }
    }
コード例 #2
0
ファイル: Parser,Lexer.cs プロジェクト: brandonc/curtsy
        // ### FileParser
        // File parser does two things: It adds types that it encounters to the specified `FoundTypes`
        // object and emits lines of code and comments as they are encountered.
        //
        // The `FoundTypes` instance will be used later on to hyperlink the files together.
        public FileParser(string path, FoundTypes foundTypes, PathHelper pathHelper)
        {
            using (StreamReader reader = new StreamReader(path))
            {
                this.tokens = Lexer.Tokenize(reader);
            }

            this.types = foundTypes;
            this.path = path;
            this.pathHelper = pathHelper;
        }
コード例 #3
0
 /// <summary>
 /// Performs a visit for the given named type
 /// </summary>
 /// <param name="namedType">The named type</param>
 public void Visit(INamedType namedType)
 {
     if (FilterSettings.ClassFilter.Evaluate(namedType) ||
         FilterSettings.EnumFilter.Evaluate(namedType))
     {
         FoundTypes.Add(namedType);
     }
     else if (FilterSettings.ControllerFilter.Evaluate(namedType))
     {
         FoundControllers.Add(namedType);
     }
 }
コード例 #4
0
 private void RegisterFoundType(Type type)
 {
     if (!FoundTypes.Contains(type))
     {
         FoundTypes.Add(type);
         if (type.IsGenericType)
         {
             foreach (var genericArgument in type.GetGenericArguments())
             {
                 RegisterFoundType(genericArgument);
             }
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Visits an external type, which is always assumed to be a found class type
 /// </summary>
 /// <param name="namedType">The named type object</param>
 public void VisitExternalType(INamedType namedType)
 {
     FoundTypes.Add(namedType);
 }
コード例 #6
0
ファイル: Curtsy.cs プロジェクト: brandonc/curtsy
        // Generates html documents and writes them to the specified destination directory.
        public void Generate(string destinationDirectory)
        {
            FoundTypes typeMap = new FoundTypes();
            List<OutputUnit> output = new List<OutputUnit>();

            foreach (string codefile in this.Sources)
            {
                List<Section> sections = new List<Section>();
                var hasCode = false;
                var docsText = new StringBuilder();
                var codeText = new StringBuilder();

                Action<string, string, int, int, int> save = (string docs, string code, int codeStartLine, int s, int e) =>
                {
                    sections.Add(new Section() { DocsHtml = docs, CodeHtml = code, CodeStartLine = codeStartLine, StartLine = s, EndLine = e });
                };

                int? codeStart = null;
                int? start = null;
                int? end = null;

                FileParser parser = new FileParser(codefile, typeMap, this.RootPathHelper);
                parser.EmitCommentLine += delegate(string line, int sourceLineNumber)
                {
                    if (!start.HasValue)
                        start = sourceLineNumber;

                    if (hasCode)
                    {
                        end = sourceLineNumber;

                        save(docsText.ToString(), codeText.ToString(), codeStart.HasValue ? codeStart.Value : 1, start.Value, end.Value);
                        docsText.Clear();
                        codeText.Clear();
                        hasCode = false;
                        codeStart = start = end = null;
                    } else
                    {
                        end = sourceLineNumber;
                    }

                    if (line.IndexOfPattern(@"//\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion)") == 0)
                        return; // Discard commented preprocessor commands

                    docsText.AppendLine(line.TrimStart(' ', '\t', '/', '*'));
                };

                parser.EmitLine += delegate(string line, int sourceLineNumber)
                {
                    if (!codeStart.HasValue)
                        codeStart = sourceLineNumber;

                    if (!start.HasValue)
                        start = sourceLineNumber;

                    end = sourceLineNumber;
                    codeText.AppendLine(line);
                    hasCode = true;
                };

                parser.Parse();
                save(docsText.ToString(), codeText.ToString(), codeStart.HasValue ? codeStart.Value : 0, start.Value, end.Value);

                output.Add(new OutputUnit()
                {
                    Sections = sections,
                    CodeFile = codefile,
                    Name = RootPathHelper.MakeRelativePath(codefile),
                    SizeFormatted = GetFileSizeFormatted(codefile)
                });
            }

            Resources.WriteClientFilesTo(destinationDirectory);

            foreach (var v in output)
            {
                GenerateInternal(v.Sections, output, v.CodeFile, typeMap, destinationDirectory);
            }
        }
コード例 #7
0
ファイル: Curtsy.cs プロジェクト: brandonc/curtsy
        // Write the output for each file into the specified destination directory
        // and prepare the razor template instance with the data it needs.
        void GenerateInternal(List<Section> sections, List<OutputUnit> sources, string codefile, FoundTypes typeMap, string destinationDirectory)
        {
            var output = this.RootPathHelper.MakeRelativePath(codefile);
            var subdestination = Path.Combine(destinationDirectory, output);
            var mdexts = DownBlouse.MarkdownExtensions.AutoLink;

            Directory.CreateDirectory(Path.GetDirectoryName(subdestination).ToLower());

            string clientPathToRoot = String.Concat(Enumerable.Repeat<string>("../", output.Split(Path.DirectorySeparatorChar).Length - 1));

            Func<string, string> getSourcePath = (string s) =>
            {
                return Path.Combine(clientPathToRoot, Path.ChangeExtension(s, ".html").ToLower()).Replace(Path.DirectorySeparatorChar, '/');
            };

            string typebounds = @"[\s\(;:,]+";

            foreach (Section s in sections)
            {
                // This block handles the possibility of XML embedded into the comments, signalling
                // visual studio style xml documentation. Only `remarks` and `summary` are used and everything else
                // is discarded.
                MatchData xmlmatches = s.DocsHtml.MatchesPattern(
                    @"\<summary\>(.+)\<\/summary\>|\<remarks\>(.+)\<\/remarks\>", "s"
                );

                if (xmlmatches != null && xmlmatches.Count > 3) {
                    s.DocsHtml = DownBlouse.DownBlouse.Markdownify(xmlmatches[1] + System.Environment.NewLine + System.Environment.NewLine + xmlmatches[3], mdexts);
                } else if (xmlmatches != null && xmlmatches.Count > 1) {
                    s.DocsHtml = DownBlouse.DownBlouse.Markdownify(xmlmatches[1], mdexts);
                } else if (s.DocsHtml.HasPattern(@"\<(example|exception|param|permission|returns|seealso|include)\>")) {
                    s.DocsHtml = String.Empty;
                } else {
                    s.DocsHtml = DownBlouse.DownBlouse.Markdownify(s.DocsHtml, mdexts);
                }

                s.CodeHtml = System.Web.HttpUtility.HtmlEncode(s.CodeHtml);

                foreach (FoundTypes.TypeInfo type in typeMap)
                {
                    string pattern;

                    if (type.Name.IndexOf('<') > 0)
                        pattern = "(namespace)?(" + typebounds + ")(" + type.Name.Sub(@"\<\w+\>", @"&lt;\w+&gt;") + ")(" + typebounds + ")";

                    pattern = "(namespace)?(" + typebounds + ")(" + type.Name + ")(" + typebounds + ")";

                    if (type.File != RootPathHelper.MakeRelativePath(codefile))
                        s.CodeHtml = s.CodeHtml.GSub(pattern, (Match m) => {
                            if (String.IsNullOrEmpty(m.Groups[1].Value))
                                return String.Format("{0}<a href=\"" + getSourcePath(type.File) + "\">{1}</a>{2}", m.Groups[2].Value, m.Groups[3].Value, m.Groups[4].Value);
                            else
                                return m.Groups[0].Value;
                        });
                }
            }

            var htmlTemplate = Resources.CreateRazorTemplateInstance();
            htmlTemplate.Title = Path.GetFileName(codefile);
            htmlTemplate.GetResourcePath = (string s) => Path.Combine(clientPathToRoot, s);
            htmlTemplate.GetSourcePath = getSourcePath;
            htmlTemplate.Sections = sections;
            htmlTemplate.Sources = sources;

            htmlTemplate.Execute();

            File.WriteAllText(Path.ChangeExtension(subdestination, ".html").ToLower(), htmlTemplate.Buffer.ToString()); // Overwrites existing file
        }