Exemple #1
0
 private void LoadSnippetOptions()
 {
     foreach (SnippetOptions options in SnippetOptions.LoadAvailableOptions())
     {
         CurrentOptions = options;
         break;
     }
 }
        private static SnippetOptions FromXmlElement(XmlElement element)
        {
            SnippetOptions ret = new SnippetOptions(element.Attributes["name"].Value);

            foreach (XmlElement tag in element.GetElementsByTagName("Assembly"))
            {
                ret.Assemblies.Add(tag.Attributes["name"].Value);
            }
            foreach (XmlElement tag in element.GetElementsByTagName("Namespace"))
            {
                ret.Namespaces.Add(tag.Attributes["name"].Value);
            }
            foreach (XmlElement tag in element.GetElementsByTagName("CompilerOption"))
            {
                ret.CompilerOptions[tag.Attributes["name"].Value] = tag.Attributes["value"].Value;
            }
            return(ret);
        }
        public static IEnumerable <SnippetOptions> LoadAvailableOptions()
        {
            IList <SnippetOptions> ret = new List <SnippetOptions>();

            XmlDocument doc = new XmlDocument();

            if (System.IO.File.Exists(OptionsFile))
            {
                doc.Load(OptionsFile);
                foreach (XmlElement element in doc.DocumentElement.GetElementsByTagName("SnippetOptions"))
                {
                    ret.Add(FromXmlElement(element));
                }
            }
            else
            {
                SnippetOptions defaultOptions = new SnippetOptions("default");
                defaultOptions.Assemblies.Add("System");
                defaultOptions.Assemblies.Add("System.Windows.Forms");
                defaultOptions.Assemblies.Add("System.Core");
                defaultOptions.Namespaces.Add("System");
                defaultOptions.Namespaces.Add("System.Text");
                defaultOptions.Namespaces.Add("System.Text.RegularExpressions");
                defaultOptions.Namespaces.Add("System.IO");
                defaultOptions.Namespaces.Add("System.Collections");
                defaultOptions.Namespaces.Add("System.Collections.Generic");
                defaultOptions.Namespaces.Add("System.ComponentModel");
                defaultOptions.Namespaces.Add("System.Windows.Forms");
                defaultOptions.Namespaces.Add("System.Threading");
                defaultOptions.Namespaces.Add("System.Reflection");

                defaultOptions.CompilerOptions["CompilerVersion"] = "v3.5";

                ret.Add(defaultOptions);
            }

            return(ret);
        }
        public static IEnumerable<SnippetOptions> LoadAvailableOptions()
        {
            IList<SnippetOptions> ret = new List<SnippetOptions>();

            XmlDocument doc = new XmlDocument();
            if (System.IO.File.Exists(OptionsFile))
            {
                doc.Load(OptionsFile);
                foreach (XmlElement element in doc.DocumentElement.GetElementsByTagName("SnippetOptions"))
                {
                    ret.Add(FromXmlElement(element));
                }
            }
            else
            {
                SnippetOptions defaultOptions = new SnippetOptions("default");
                defaultOptions.Assemblies.Add("System");
                defaultOptions.Assemblies.Add("System.Windows.Forms");
                defaultOptions.Assemblies.Add("System.Core");
                defaultOptions.Namespaces.Add("System");
                defaultOptions.Namespaces.Add("System.Text");
                defaultOptions.Namespaces.Add("System.Text.RegularExpressions");
                defaultOptions.Namespaces.Add("System.IO");
                defaultOptions.Namespaces.Add("System.Collections");
                defaultOptions.Namespaces.Add("System.Collections.Generic");
                defaultOptions.Namespaces.Add("System.ComponentModel");
                defaultOptions.Namespaces.Add("System.Windows.Forms");
                defaultOptions.Namespaces.Add("System.Threading");
                defaultOptions.Namespaces.Add("System.Reflection");

                defaultOptions.CompilerOptions["CompilerVersion"] = "v3.5";

                ret.Add(defaultOptions);
            }

            return ret;
        }
 private void LoadSnippetOptions()
 {
     foreach (SnippetOptions options in SnippetOptions.LoadAvailableOptions())
     {
         CurrentOptions = options;
         break;
     }
 }
 /// <summary>
 /// Generates a snippet from the given text, with the given options.
 /// </summary>
 public Snippet(string snippetText, SnippetOptions options)
 {
     this.snippetText = snippetText;
     this.options = options;
 }
 private static SnippetOptions FromXmlElement(XmlElement element)
 {
     SnippetOptions ret = new SnippetOptions(element.Attributes["name"].Value);
     foreach (XmlElement tag in element.GetElementsByTagName("Assembly"))
     {
         ret.Assemblies.Add(tag.Attributes["name"].Value);
     }
     foreach (XmlElement tag in element.GetElementsByTagName("Namespace"))
     {
         ret.Namespaces.Add(tag.Attributes["name"].Value);
     }
     foreach (XmlElement tag in element.GetElementsByTagName("CompilerOption"))
     {
         ret.CompilerOptions[tag.Attributes["name"].Value] = tag.Attributes["value"].Value;
     }
     return ret;
 }
 /// <summary>
 /// Generates a snippet from the given text, with the given options.
 /// </summary>
 public Snippet(string snippetText, SnippetOptions options)
 {
     this.snippetText = snippetText;
     this.options     = options;
 }