Beispiel #1
0
        /// <summary>
        /// Saves the set of groups.
        /// </summary>
        public void SaveGroups(IEnumerable <CodeSnippetGroup> groups)
        {
            lock (lockObj) {
                activeGroups = null;
                List <CodeSnippetGroup> modifiedGroups = new List <CodeSnippetGroup>();

                foreach (var group in groups)
                {
                    var defaultGroup = defaultSnippets.FirstOrDefault(i => i.Extensions == group.Extensions);

                    IEnumerable <CodeSnippet> saveSnippets = group.Snippets;

                    if (defaultGroup != null)
                    {
                        saveSnippets = group.Snippets.Except(defaultGroup.Snippets);
                    }

                    // save all groups, even if they're empty
                    var copy = new CodeSnippetGroup()
                    {
                        Extensions = group.Extensions
                    };
                    //copy.Snippets.AddRange(saveSnippets);
                    modifiedGroups.Add(copy);
                }

                //PropertyService.Set("CodeSnippets", modifiedGroups);
            }
        }
Beispiel #2
0
        public CodeSnippet FindSnippet(string extension, string name)
        {
            CodeSnippetGroup g = FindGroup(extension);

            if (g != null)
            {
                return(g.Snippets.FirstOrDefault(s => s.Name == name));
            }
            return(null);
        }