Exemplo n.º 1
0
        public void SetCustomField <T>(string fieldName, T value)
        {
            if (!CustomFieldData.ContainsKey(fieldName))
            {
                throw new Exception(fieldName + " is not a registered field.");
            }

            CustomFieldData[fieldName] = (string)ExtensibleTypeConverter.ChangeType(value, typeof(string));
        }
Exemplo n.º 2
0
        public static void Set <TType>(this IDictionary <string, string> dictionary, string key, TType value)
        {
            if (!dictionary.ContainsKey(key))
            {
                dictionary.Add(key, null);
            }

            dictionary[key] = ExtensibleTypeConverter.ChangeType <string>(value);
        }
Exemplo n.º 3
0
        private Tuple <object, object> DuckType(Tuple <object, object> values)
        {
            var leftType  = values.Item1?.GetType();
            var rightType = values.Item2?.GetType();

            if (Type.Equals(leftType, rightType))
            {
                return(values);
            }

            var nonStringType = new[] { leftType, rightType }.FirstOrDefault(x => x != null && x != typeof(string));

            if (nonStringType == null)
            {
                return(values);
            }

            var newValue1 = ExtensibleTypeConverter.ChangeType(values.Item1, nonStringType);
            var newValue2 = ExtensibleTypeConverter.ChangeType(values.Item1, nonStringType);

            return(new Tuple <object, object>(newValue1, newValue2));
        }
Exemplo n.º 4
0
        public static TType Get <TType>(this IDictionary <string, string> dictionary, string key)
        {
            var val = dictionary[key];

            return(ExtensibleTypeConverter.ChangeType <TType>(val));
        }
 public string GetValue()
 {
     return(ExtensibleTypeConverter.ChangeType <string>(_config));
 }
 public void SetValue(string newValue)
 {
     _config = ExtensibleTypeConverter.ChangeType <ContentListConfiguration>(newValue);
     DataBind();
 }