Example #1
0
        public PluginExtendedPropertyCollection(PluginElement owner) : base(StringComparer.OrdinalIgnoreCase)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            _owner = owner;
        }
Example #2
0
        internal PluginExtendedProperty(PluginElement owner, string name, PluginTreeNode valueNode, Plugin plugin) : base(owner, name, valueNode)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            _plugin = plugin;
        }
        internal protected PluginElementProperty(PluginElement owner, string name, string rawValue)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            _name     = name.Trim();
            _owner    = owner ?? throw new ArgumentNullException(nameof(owner));
            _rawValue = rawValue;
        }
        internal protected PluginElementProperty(PluginElement owner, string name, PluginTreeNode valueNode)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            _name      = name.Trim();
            _owner     = owner ?? throw new ArgumentNullException(nameof(owner));
            _valueNode = valueNode ?? throw new ArgumentNullException(nameof(valueNode));
            _rawValue  = valueNode.FullPath;
        }
Example #5
0
        internal static object ResolveValue(PluginElement element, string text, string memberName, Type memberType, object defaultValue)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            if (string.IsNullOrWhiteSpace(text))
            {
                return(Zongsoft.Common.Convert.ConvertValue(text, memberType, defaultValue));
            }

            object result = text;

            //进行解析器处理,如果解析器无法处理将会返回传入的原始值
            if (Parsers.Parser.CanParse(text))
            {
                if (element is Builtin)
                {
                    result = Parsers.Parser.Parse(text, (Builtin)element, memberName, memberType);
                }
                else if (element is PluginTreeNode)
                {
                    result = Parsers.Parser.Parse(text, (PluginTreeNode)element, memberName, memberType);
                }
                else
                {
                    throw new ArgumentException(string.Format("Can not support the '{0}' element type.", element.GetType()));
                }
            }

            //对最后的结果进行类型转换,如果指定的类型为空,该转换操作不会执行任何动作
            if (memberType == null)
            {
                return(result);
            }
            else
            {
                return(Zongsoft.Common.Convert.ConvertValue(result, memberType, defaultValue));
            }
        }
 public PluginExtendedPropertyCollection(PluginElement owner) : base(StringComparer.OrdinalIgnoreCase)
 {
     _owner = owner ?? throw new ArgumentNullException(nameof(owner));
 }
Example #7
0
 internal PluginExtendedProperty(PluginElement owner, string name, string rawValue, Plugin plugin) : base(owner, name, rawValue)
 {
     _plugin = plugin ?? throw new ArgumentNullException(nameof(plugin));
 }