コード例 #1
0
        private void loadSufficientGroup(ConfigGramer.Item item, ref Aggregation aggregation)
        {
            ASTQualifier[] qualifiers =
            {
                new ASTQualifier(ItemType.SETTING),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.LIST),
                new ASTQualifier(ItemType.VALUE_LIST)
            };
            if (item.context == ItemType.SETTING_LIST)
            {
                ConfigGramer._SettingList sufficientList = (ConfigGramer._SettingList)item.value;
                for (int i = 0; i < sufficientList.Count; i++)
                {
                    switch (sufficientList.Value[i].Name.Value)
                    {
                    case "congress_group":
                        qualifiers[0].itemQualifier = "congress_group";
                        aggregation.Congress        = configuration.GetItem(item, qualifiers).GetStringList();
                        break;

                    case "necessary_group":
                        qualifiers[0].itemQualifier = "necessary_group";
                        aggregation.NecessaryGroup  = configuration.GetItem(item, qualifiers).GetStringList();
                        break;

                    default:
                        return;
                    }
                }
            }
        }
コード例 #2
0
        private void LoadAggregation(ConfigGramer configuration)
        {
            ConfigGramer.Item result = configuration.GetItem(
                new ASTQualifier(ItemType.CONFIGURATION),
                new ASTQualifier(ItemType.SETTING_LIST),
                new ASTQualifier(ItemType.SETTING, "aggregation"),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.GROUP),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.SETTING_LIST)
                );

            if (result.IsEmpty()) //checks to make sure we have an aggregation setting with values in it
            {
                return;
            }

            ConfigGramer._SettingList valueList  = (ConfigGramer._SettingList)result.value;
            ASTQualifier[]            qualifiers =
            {
                new ASTQualifier(ItemType.SETTING),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.SCALAR_VALUE),
                new ASTQualifier(ItemType.STRING)
            };
            Aggregation aggregation = new Aggregation();

            for (int i = 0; i < valueList.Count; i++)
            {
                switch (valueList.Value[i].Name.Value)
                {
                case "congress_threshold":
                    qualifiers[3].itemType      = ItemType.FLOAT;
                    qualifiers[0].itemQualifier = "congress_threshold";
                    aggregation.Threshold       = (configuration.GetItem(result, qualifiers).GetFloat() * 100).ToString();

                    break;

                case "sufficient":    //{PluginManager.ConfigGramer._Value} {PluginManager.ConfigGramer._Group} {PluginManager.ConfigGramer._SettingList}

                    loadSufficientGroup(configuration.GetItem(
                                            result,
                                            new ASTQualifier(ItemType.SETTING, "sufficient"),
                                            new ASTQualifier(ItemType.VALUE),
                                            new ASTQualifier(ItemType.GROUP),
                                            new ASTQualifier(ItemType.SETTING_LIST)
                                            ), ref aggregation);

                    break;
                }
            }

            PublicAggregation  = aggregation;
            NumberTextBox.Text = aggregation.Threshold;
        }
コード例 #3
0
        private void LoadAddons(ConfigGramer configuration)
        {
            addonList = new List <AddonItem>();

            ConfigGramer.Item result = configuration.GetItem(
                new ASTQualifier(ItemType.CONFIGURATION),
                new ASTQualifier(ItemType.SETTING_LIST),
                new ASTQualifier(ItemType.SETTING, "addons"),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.LIST),
                new ASTQualifier(ItemType.VALUE_LIST)
                );

            if (result.IsEmpty())
            {
                return;
            }

            ConfigGramer._ValueList    valueList = (ConfigGramer._ValueList)result.value;
            List <ConfigGramer._Value> list      = valueList.Value;

            ASTQualifier[] qualifiers =
            {
                new ASTQualifier(ItemType.SETTING),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.SCALAR_VALUE),
                new ASTQualifier(ItemType.STRING)
            };

            for (int i = 0; i < list.Count; i++)
            {
                ConfigGramer.Item listItem = configuration.GetItem(
                    result,
                    new ASTQualifier(ItemType.VALUE, i.ToString()),
                    new ASTQualifier(ItemType.GROUP),
                    new ASTQualifier(ItemType.SETTING_LIST)
                    );

                AddonItem addon = new AddonItem();

                qualifiers[3].itemType      = ItemType.STRING;
                qualifiers[0].itemQualifier = "name";
                addon.Name = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "description";
                addon.Description           = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "version";
                addon.Version = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "type";
                addon.Type = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "path";
                addon.Path = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "enabled";
                qualifiers[3].itemType      = ItemType.BOOLEAN;
                addon.Enabled = configuration.GetItem(listItem, qualifiers).GetBoolean();

                addonList.Add(addon);
            }

            if (addonList.Count > DEFAULT_NUM_OPTIONS)
            {
                ExpandAddonListButton.Visibility = Visibility.Visible;
                ExpandAddonListButton.Content    = "▲";
                VisibleAddonList = addonList.GetRange(0, 3);
            }
            else
            {
                ExpandAddonListButton.Visibility = Visibility.Collapsed;
                VisibleAddonList = addonList;
            }

            AddonOptionsListView.ItemsSource = VisibleAddonList;
        }
コード例 #4
0
        private void LoadPlugins(ConfigGramer configuration)
        {
            pluginList = new List <PluginItem>();

            ConfigGramer.Item result = configuration.GetItem(
                new ASTQualifier(ItemType.CONFIGURATION),
                new ASTQualifier(ItemType.SETTING_LIST),
                new ASTQualifier(ItemType.SETTING, "plugins"),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.LIST),
                new ASTQualifier(ItemType.VALUE_LIST)
                );

            if (result.IsEmpty())
            {
                return;
            }

            ConfigGramer._ValueList    valueList = (ConfigGramer._ValueList)result.value;
            List <ConfigGramer._Value> list      = valueList.Value;

            ASTQualifier[] qualifiers =
            {
                new ASTQualifier(ItemType.SETTING),
                new ASTQualifier(ItemType.VALUE),
                new ASTQualifier(ItemType.SCALAR_VALUE),
                new ASTQualifier(ItemType.STRING)
            };

            for (int i = 0; i < list.Count; i++)
            {
                ConfigGramer.Item listItem = configuration.GetItem(
                    result,
                    new ASTQualifier(ItemType.VALUE, i.ToString()),
                    new ASTQualifier(ItemType.GROUP),
                    new ASTQualifier(ItemType.SETTING_LIST)
                    );

                PluginItem plugin = new PluginItem();

                qualifiers[3].itemType      = ItemType.STRING;
                qualifiers[0].itemQualifier = "name";
                plugin.Name = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "description";
                plugin.Description          = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "version";
                plugin.Version = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "type";
                plugin.Type = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "handler";
                plugin.Handler = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "path";
                plugin.Path = configuration.GetItem(listItem, qualifiers).GetString();

                qualifiers[0].itemQualifier = "enabled";
                qualifiers[3].itemType      = ItemType.BOOLEAN;
                plugin.Enabled = configuration.GetItem(listItem, qualifiers).GetBoolean();
                plugin.Updated = false;

                // TODO load necessary and congress groups membership from
                pluginList.Add(plugin);
            }

            if (pluginList.Count > DEFAULT_NUM_OPTIONS)
            {
                ExpandPluginListButton.Visibility = Visibility.Visible;
                ExpandPluginListButton.Content    = "▼"; // ▲
                VisiblePluginList = pluginList.GetRange(0, 3);
            }
            else
            {
                ExpandPluginListButton.Visibility = Visibility.Collapsed;
                VisiblePluginList = pluginList;
            }

            ConfigurationSettingsGridView.ItemsSource = VisiblePluginList;
        }