GetSnippets() public static method

Gets the complete list of the Snippets.
public static GetSnippets ( ) : List
return List
Esempio n. 1
0
        /// <summary>
        /// Loads and prints the snippets.
        /// </summary>
        private void LoadSnippets()
        {
            StringBuilder sb = new StringBuilder(1000);

            foreach (Snippet s in Snippets.GetSnippets())
            {
                string[] parameters = Snippets.ExtractParameterNames(s);
                int      paramCount = parameters.Length;
                string   label;
                if (paramCount == 0)
                {
                    label = s.Name;
                    sb.AppendFormat(@"<a href=""#"" title=""{0}"" onclick=""javascript:return InsertMarkup('&#0123;s:{1}&#0125;');"" class=""menulink"">{0}</a>",
                                    label, s.Name);
                }
                else
                {
                    bool isPositional = IsSnippetPositional(parameters);
                    label = string.Format("{0} ({1} {2})", s.Name, paramCount, Properties.Messages.Parameters);
                    sb.AppendFormat(@"<a href=""#"" title=""{0}"" onclick=""javascript:return InsertMarkup('&#0123;s:{1}{2}{3}&#0125;');"" class=""menulink"">{0}</a>",
                                    label, s.Name, isPositional ? "" : "\\r\\n", GetParametersPlaceHolders(parameters, isPositional));
                }
            }
            if (sb.Length == 0)
            {
                sb.Append("<i>" + Properties.Messages.NoSnippets + "</i>");
            }
            lblSnippets.Text = sb.ToString();
        }
        protected void rptSnippetsTemplates_DataBinding(object sender, EventArgs e)
        {
            List <Snippet>         snippets  = Snippets.GetSnippets();
            List <ContentTemplate> templates = Templates.GetTemplates();

            List <SnippetTemplateRow> result = new List <SnippetTemplateRow>(snippets.Count + templates.Count);

            foreach (Snippet snip in snippets)
            {
                result.Add(new SnippetTemplateRow(snip, "S." + snip.Name == txtCurrentElement.Value));
            }
            foreach (ContentTemplate temp in templates)
            {
                result.Add(new SnippetTemplateRow(temp, "T." + temp.Name == txtCurrentElement.Value));
            }

            rptSnippetsTemplates.DataSource = result;
        }