Exemple #1
0
        public int GetInt(string key)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToInt(map[key]));
            }

            return(0);
        }
Exemple #2
0
        public int GetInt(string key, int defValue)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToInt(map[key]));
            }

            return(defValue);
        }
Exemple #3
0
        public long GetLong(string key)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToLong(map[key]));
            }

            return(0L);
        }
Exemple #4
0
        public long GetLong(string key, long defValue)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToLong(map[key]));
            }

            return(defValue);
        }
Exemple #5
0
        public string GetString(string key)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToString(map[key]));
            }

            return(null);
        }
Exemple #6
0
        public WMap(object source)
        {
            map = WUtil.ToDictionary(source);

            if (map == null)
            {
                map = new Dictionary <string, object>();
            }
        }
Exemple #7
0
        public DateTime GetDateTime(string key, DateTime defValue)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToDateTime(map[key], defValue));
            }

            return(defValue);
        }
Exemple #8
0
        public DateTime GetDateTime(string key)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToDateTime(map[key]));
            }

            return(DateTime.MinValue);
        }
Exemple #9
0
        public double GetDouble(string key, double defValue)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToDouble(map[key]));
            }

            return(defValue);
        }
Exemple #10
0
        public double GetDouble(string key)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToDouble(map[key]));
            }

            return(0.0d);
        }
Exemple #11
0
        public bool IsBlank(int index)
        {
            string value = WUtil.ToString(list[index]);

            if (value != null && value.Length != 0)
            {
                return false;
            }

            return true;
        }
Exemple #12
0
        public IList <object> GetList(string key, bool notNull = false)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToList(map[key]));
            }

            if (notNull)
            {
                return(new List <object>());
            }

            return(null);
        }
Exemple #13
0
        public IDictionary <string, object> GetDictionary(string key, bool notNull = false)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToDictionary(map[key]));
            }

            if (notNull)
            {
                return(new Dictionary <string, object>());
            }

            return(null);
        }
Exemple #14
0
        public object[] GetArray(string key, bool notNull = false)
        {
            if (map.ContainsKey(key))
            {
                return(WUtil.ToArray(map[key]));
            }

            if (notNull)
            {
                return(new object[0]);
            }

            return(null);
        }
Exemple #15
0
        public bool IsBlank(string key)
        {
            if (map.ContainsKey(key))
            {
                string value = WUtil.ToString(map[key]);

                if (value != null && value.Length != 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #16
0
        public IList<object> GetList(int index, bool notNull = false)
        {
            object value = list[index];

            if (value != null)
            {
                return WUtil.ToList(value);
            }

            if (notNull)
            {
                return new List<object>();
            }

            return null;
        }
Exemple #17
0
        public object[] GetArray(int index, bool notNull = false)
        {
            object value = list[index];

            if(value != null)
            {
                return WUtil.ToArray(value);
            }

            if (notNull)
            {
                return new object[0];
            }

            return null;
        }
Exemple #18
0
        public IDictionary<string, object> GetDictionary(int index, bool notNull = false)
        {
            object value = list[index];

            if (value != null)
            {
                return WUtil.ToDictionary(value);
            }

            if (notNull)
            {
                return new Dictionary<string, object>();
            }

            return null;
        }
Exemple #19
0
        public string GetString(string key, string defValue)
        {
            if (map.ContainsKey(key))
            {
                string result = WUtil.ToString(map[key]);

                if (result == null)
                {
                    return(defValue);
                }

                return(result);
            }

            return(defValue);
        }
Exemple #20
0
        public static object[] ConvertParameters(ParameterInfo[] arrayOfParameterInfo, object[] parameters)
        {
            if (arrayOfParameterInfo.Length != parameters.Length)
            {
                return(null);
            }

            for (int i = 0; i < arrayOfParameterInfo.Length; i++)
            {
                object value = parameters[i];

                if (value == null)
                {
                    continue;
                }

                ParameterInfo parameterInfo = arrayOfParameterInfo[i];

                Type typePar = parameterInfo.ParameterType;

                if (value is JValue)
                {
                    value = ((JValue)value).Value;

                    parameters[i] = value;
                }

                Type typeObj = value.GetType();

                if (!typePar.IsAssignableFrom(typeObj))
                {
                    parameters[i] = WUtil.ToObjectOf(value, typePar);
                }
            }

            return(parameters);
        }
Exemple #21
0
        public static object[] GetParameters(ParameterInfo[] arrayOfParameterInfo, object[] parameters)
        {
            if (arrayOfParameterInfo.Length != parameters.Length)
            {
                return(null);
            }

            for (int i = 0; i < arrayOfParameterInfo.Length; i++)
            {
                object value = parameters[i];

                if (value == null)
                {
                    continue;
                }

                ParameterInfo parameterInfo = arrayOfParameterInfo[i];

                Type typePar = parameterInfo.ParameterType;

                if (value is JValue)
                {
                    value = ((JValue)value).Value;

                    parameters[i] = value;
                }

                Type typeObj = value.GetType();

                if (!typePar.IsAssignableFrom(typeObj))
                {
                    var typeParName = typePar.Namespace + "." + typePar.Name;

                    if (!typeParName.StartsWith("System."))
                    {
                        // IDictionary -> Data Class

                        if (value is IDictionary <string, object> )
                        {
                            parameters[i] = WUtil.CreateObject((IDictionary <string, object>)value, typePar);
                            continue;
                        }
                        else if (value is JObject)
                        {
                            parameters[i] = WUtil.CreateObject((JObject)value, typePar);
                            continue;
                        }
                    }
                    else if (typeof(IDictionary <string, object>).IsAssignableFrom(typePar))
                    {
                        // Data Class -> IDictionary

                        var typeObjName = typeObj.Namespace + "." + typeObj.Name;

                        if (value is IDictionary <string, object> )
                        {
                            continue;
                        }
                        else if (value is JObject)
                        {
                            parameters[i] = WUtil.ToDictionary(value);
                            continue;
                        }
                        else if (!typeObjName.StartsWith("System."))
                        {
                            parameters[i] = WUtil.ToDictionary(value);
                            continue;
                        }
                    }
                    else if (typeof(Array).IsAssignableFrom(typePar))
                    {
                        parameters[i] = WUtil.ToArrayOf(value, typePar.GetElementType());
                        continue;
                    }
                    else if (typeof(IEnumerable <object>).IsAssignableFrom(typePar))
                    {
                        Type elementType = typePar.GetElementType();
                        if (elementType == null)
                        {
                            Type[] generciArguments = typePar.GetGenericArguments();
                            elementType = generciArguments != null && generciArguments.Length > 0 ? generciArguments[0] : null;
                        }
                        parameters[i] = WUtil.ToListOf(value, elementType);
                        continue;
                    }
                    else if (value is Int64)
                    {
                        if (typePar.Equals(typeof(Int32)))
                        {
                            parameters[i] = Convert.ToInt32(value);
                            continue;
                        }
                        else if (typePar.Equals(typeof(Double)))
                        {
                            parameters[i] = Convert.ToDouble(value);
                            continue;
                        }
                    }
                    else if (value is Int32)
                    {
                        if (typePar.Equals(typeof(Int64)))
                        {
                            parameters[i] = Convert.ToInt64(value);
                            continue;
                        }
                        else if (typePar.Equals(typeof(Double)))
                        {
                            parameters[i] = Convert.ToDouble(value);
                            continue;
                        }
                    }
                    else if (value is Double)
                    {
                        if (typePar.Equals(typeof(Int32)))
                        {
                            parameters[i] = Convert.ToInt32(value);
                            continue;
                        }
                        else if (typePar.Equals(typeof(Int64)))
                        {
                            parameters[i] = Convert.ToInt64(value);
                            continue;
                        }
                    }
                    return(null);
                }
            }

            return(parameters);
        }
Exemple #22
0
 public string GetString(int index, string defValue)
 {
     return WUtil.ToString(list[index], defValue);
 }
Exemple #23
0
 public int GetInt(int index)
 {
     return WUtil.ToInt(list[index]);
 }
Exemple #24
0
 public int GetInt(int index, int defValue)
 {
     return WUtil.ToInt(list[index], defValue);
 }
Exemple #25
0
 public long GetLong(int index)
 {
     return WUtil.ToLong(list[index]);
 }
Exemple #26
0
 public long GetLong(int index, long defValue)
 {
     return WUtil.ToLong(list[index], defValue);
 }
Exemple #27
0
 public double GetDouble(int index)
 {
     return WUtil.ToDouble(list[index]);
 }
Exemple #28
0
 public double GetDouble(int index, double defValue)
 {
     return WUtil.ToDouble(list[index], defValue);
 }
Exemple #29
0
 public DateTime GetDateTime(int index)
 {
     return WUtil.ToDateTime(list[index]);
 }
Exemple #30
0
 public DateTime GetDateTime(int index, DateTime defValue)
 {
     return WUtil.ToDateTime(list[index], defValue);
 }