Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Feature"/> class.
        /// </summary>
        /// <param name="resourceManager">The resource manager for localization</param>
        /// <param name="node">The XML node from the plugin config file</param>
        /// <param name="pluginDescriptor">The plugin descriptor.</param>
        public Feature(ResourceManager resourceManager, XmlNode node, PluginDescriptor pluginDescriptor)
        {
            Util.ThrowIfParameterNull(node, "node");
            Util.ThrowIfParameterNull(pluginDescriptor, "pluginDescriptor");

            this.node         = node;
            _resourceManager  = resourceManager;
            _pluginDescriptor = pluginDescriptor;

            _name        = Helpers.GetStringXmlAttribute(node, ATT_NAME, "");
            _label       = Helpers.GetStringXmlAttribute(node, ATT_LABEL, "");
            _description = Helpers.GetStringXmlAttribute(node, ATT_DESCRIPTION, "");
            _tooltip     = Helpers.GetStringXmlAttribute(node, ATT_TOOLTIP, "");
            _icon        = LoadIcon(Helpers.GetStringXmlAttribute(node, ATT_ICON, ""));
            _search      = PluginDescriptor.GetSearch(Helpers.GetStringXmlAttribute(node, ATT_SEARCH, ""));

            // localize
            if (_resourceManager != null)
            {
                string label = _resourceManager.GetString(string.Format("{0}.{1}", Name, ATT_LABEL));
                _label = string.IsNullOrEmpty(label) ? _label : label;

                string description = _resourceManager.GetString(string.Format("{0}.{1}", Name, ATT_DESCRIPTION));
                _description = string.IsNullOrEmpty(description) ? _description : description;

                string tooltip = _resourceManager.GetString(string.Format("{0}.{1}", Name, ATT_TOOLTIP));
                _tooltip = string.IsNullOrEmpty(tooltip) ? _tooltip : tooltip;

                string icon = _resourceManager.GetString(string.Format("{0}.{1}", Name, ATT_ICON));
                _icon = string.IsNullOrEmpty(icon) ? _icon : LoadIcon(icon);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Feature"/> class.
        /// </summary>
        /// <param name="resourceManager">The resource manager for localization</param>
        /// <param name="node">The XML node from the plugin config file</param>
        /// <param name="pluginDescriptor">The plugin descriptor.</param>
        protected Feature(ResourceManager resourceManager, XmlNode node, PluginDescriptor pluginDescriptor)
        {
            Util.ThrowIfParameterNull(node, "node");
            Util.ThrowIfParameterNull(pluginDescriptor, "pluginDescriptor");

            this.node        = node;
            _resourceManager = resourceManager;
            PluginDescriptor = pluginDescriptor;

            Name        = Helpers.GetStringXmlAttribute(node, ATT_NAME, "");
            Label       = Helpers.GetStringXmlAttribute(node, ATT_LABEL, "");
            Description = Helpers.GetStringXmlAttribute(node, ATT_DESCRIPTION, "");
            Tooltip     = Helpers.GetStringXmlAttribute(node, ATT_TOOLTIP, "");
            Icon        = LoadIcon(Helpers.GetStringXmlAttribute(node, ATT_ICON, ""));
            Search      = PluginDescriptor.GetSearch(Helpers.GetStringXmlAttribute(node, ATT_SEARCH, ""));

            // localize
            if (_resourceManager != null)
            {
                string label = _resourceManager.GetString($"{Name}.{ATT_LABEL}");
                if (!string.IsNullOrEmpty(label))
                {
                    Label = label;
                }

                string description = _resourceManager.GetString($"{Name}.{ATT_DESCRIPTION}");
                if (!string.IsNullOrEmpty(description))
                {
                    Description = description;
                }

                string tooltip = _resourceManager.GetString($"{Name}.{ATT_TOOLTIP}");
                if (!string.IsNullOrEmpty(tooltip))
                {
                    Tooltip = tooltip;
                }

                string icon = _resourceManager.GetString($"{Name}.{ATT_ICON}");
                if (!string.IsNullOrEmpty(icon))
                {
                    Icon = LoadIcon(icon);
                }
            }
        }