Пример #1
0
        internal static MAP LoadGlobalSettings()
        {
            if (settings != null)
            {
                return(settings);
            }

            foreach (var pkg in App.Catalog <IPackageManager>().Default().EnumeratePackages())
            {
                foreach (var e in pkg.GetMetadata(PackageSection.Settings))
                {
                    var name = Path.Combine(pkg.Directory.FullName, "data", e.String("file"));
                    var map  = ReadFile(name);

                    if (settings == null)
                    {
                        settings = map;
                    }
                    else
                    {
                        try
                        {
                            foreach (var kv in map)
                            {
                                settings.Add(kv.Key, kv.Value);
                            }
                        }
                        catch { }
                    }
                }
            }

            return(settings);
        }
Пример #2
0
 /// <summary>Initializes a new instance of the <see cref="CommandFactory"/> class.</summary>
 /// <param name="messages">The message repository.</param>
 /// <param name="users">The user repository.</param>
 /// <param name="formatter">The message formatter.</param>
 public CommandFactory(MessageRepository messages, UserRepository users, MessageFormatter formatter)
 {
     MAP.Add("->", () => new PostCommand(messages));
     MAP.Add("FOLLOWS", () => new FollowsCommand(users));
     MAP.Add("WALL", () => new WallCommand(messages, users, formatter));
     MAP.Add("", () => new ReadCommand(messages, formatter));
 }
Пример #3
0
        private KeyInput Parse(Identifier key, string shortcut)
        {
            var      arr   = shortcut.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            KeyInput chord = null;

            for (var i = 0; i < arr.Length; i++)
            {
                var mod  = Modifiers.None;
                var a    = arr[i];
                var last = i == arr.Length - 1;
                var arr2 = a.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);

                for (var j = 0; j < arr2.Length; j++)
                {
                    if (chord != null && !chords.ContainsKey(chord))
                    {
                        chords.Add(chord, null);
                    }

                    var ch = arr2[j];

                    if (j != arr2.Length - 1)
                    {
                        mod |=
                            Eq(ch, "Ctrl") ? Modifiers.Ctrl
                            : Eq(ch, "Alt") ? Modifiers.Alt
                            : Eq(ch, "Shift") ? Modifiers.Shift
                            : Eq(ch, "Win") ? Modifiers.Cmd
                            : Eq(ch, "Cmd") ? Modifiers.Cmd
                            : Eq(ch, "Move") ? Modifiers.Move
                            : Modifiers.None;
                    }
                    else
                    {
                        var input = ch.Length == 1 ? new KeyInput(mod, ch[0])
                            : new KeyInput(mod, ParseSpecialKey(ch));

                        if (j == arr2.Length - 1)
                        {
                            inputs.Add(chord ?? input, key);
                        }

                        if (chord == null)
                        {
                            chord = input;
                        }
                        else
                        {
                            chord.Chord = input;
                            chord       = input;
                        }
                    }
                }
            }

            return(chord);
        }