Exemplo n.º 1
0
        private static bool ReadValue(string s, IZXPConverter converter, Type t, out object val)
        {
            string sFormatted = s.Trim();

            switch (sFormatted.ToLower())
            {
            case "null":
                val = null;
                return(true);
            }

            // We Found An Environment Key To Use
            if (sFormatted.StartsWith("~~") && sFormatted.EndsWith("~~") && sFormatted.Length > 4)
            {
                string sEnvKey = sFormatted.Substring(2, sFormatted.Length - 4);
                return(GetEnvironment(sEnvKey, out val));
            }

            // Try To Convert The Value
            if (converter != null)
            {
                return(converter.Convert(s, out val));
            }
            else
            {
                val = ParseNew(s, t);
                return(true);
            }
        }
Exemplo n.º 2
0
 public ZXPDatum(string key, PropertyInfo pi)
 {
     Key = key;
     field = null;
     prop = pi;
     if(!ZXParser.GetConverter(Type, out Converter))
         Converter = null;
 }
Exemplo n.º 3
0
 public ZXPDatum(string key, FieldInfo fi)
 {
     Key = key;
     field = fi;
     prop = null;
     if(!ZXParser.GetConverter(Type, out Converter))
         Converter = null;
 }
Exemplo n.º 4
0
 public ZXPDatum(string key, PropertyInfo pi)
 {
     Key   = key;
     field = null;
     prop  = pi;
     if (!ZXParser.GetConverter(Type, out Converter))
     {
         Converter = null;
     }
 }
Exemplo n.º 5
0
 public ZXPDatum(string key, FieldInfo fi)
 {
     Key   = key;
     field = fi;
     prop  = null;
     if (!ZXParser.GetConverter(Type, out Converter))
     {
         Converter = null;
     }
 }
Exemplo n.º 6
0
 public static void AddConverter(Type t, IZXPConverter conv)
 {
     conversionFunctions[t] = conv;
 }
Exemplo n.º 7
0
 public static bool GetConverter(Type t, out IZXPConverter conv)
 {
     return(conversionFunctions.TryGetValue(t, out conv));
 }
Exemplo n.º 8
0
 public static bool GetConverter(Type t, out IZXPConverter conv)
 {
     return conversionFunctions.TryGetValue(t, out conv);
 }
Exemplo n.º 9
0
 public static void AddConverter(Type t, IZXPConverter conv)
 {
     conversionFunctions[t] = conv;
 }
Exemplo n.º 10
0
        private static bool ReadValue(string s, IZXPConverter converter, Type t, out object val)
        {
            string sFormatted = s.Trim();
            switch(sFormatted.ToLower()) {
                case "null":
                    val = null;
                    return true;
            }

            // We Found An Environment Key To Use
            if(sFormatted.StartsWith("~~") && sFormatted.EndsWith("~~") && sFormatted.Length > 4) {
                string sEnvKey = sFormatted.Substring(2, sFormatted.Length - 4);
                return GetEnvironment(sEnvKey, out val);
            }

            // Try To Convert The Value
            if(converter != null) return converter.Convert(s, out val);
            else {
                val = ParseNew(s, t);
                return true;
            }
        }