Beispiel #1
0
        public void Write(string groupName, HexViewGroupOption option)
        {
            if (groupName == null)
            {
                throw new ArgumentNullException(nameof(groupName));
            }
            if (option == null)
            {
                throw new ArgumentNullException(nameof(option));
            }
            if (!option.Definition.CanBeSaved)
            {
                return;
            }
            var sect = GetOrCreateOptionSection(groupName, option);

            if (!TryGetValueString(option, out string valueString))
            {
                return;
            }
            sect.Attribute(OptionValueAttr, valueString);
        }
Beispiel #2
0
        bool TryGetValue(HexViewGroupOption option, string textValue, out object value)
        {
            var type = option.Definition.Type;
            var c    = TypeDescriptor.GetConverter(type);

            try {
                value = c.ConvertFromInvariantString(textValue);
                if (type.IsValueType && value == null)
                {
                    return(false);
                }
                if (value != null && !type.IsAssignableFrom(value.GetType()))
                {
                    return(false);
                }
                return(true);
            }
            catch (FormatException) {
            }
            catch (NotSupportedException) {
            }
            value = null;
            return(false);
        }
		public void Add(HexViewGroupOption option) => Options.Add(option);
 public void Add(HexViewGroupOption option) => Options.Add(option);