Exemplo n.º 1
0
        /// <summary>Get 메소드의 generic 형</summary>
        /// <param name="key">string, 반환할 자료의 key 값</param>
        /// <param name="defaultValue">T, 예외 발생시 반환받을 기본 값</param>
        public T Get <T>(string key, T defaultValue)
        {
            object rtnValue;

            if (typeof(T).Name.Equals(typeof(String).Name))
            {
                rtnValue = "";
            }
            else
            {
                rtnValue = Activator.CreateInstance(typeof(T));
            }

            rtnValue = Get(key);
            if (rtnValue != null)
            {
                try {
                    rtnValue = AZString.Init(rtnValue).To <T>(defaultValue);
                }
                catch (Exception) {
                    rtnValue = defaultValue;
                }
            }
            else
            {
                rtnValue = defaultValue;
            }
            return((T)rtnValue);
        }
Exemplo n.º 2
0
            /// <summary>ToString 오버라이딩</summary>
            public override string ToString()
            {
                StringBuilder rtnValue = new StringBuilder();

                for (int cnti = 0; cnti < this.attribute_list.Count; cnti++)
                {
                    string str;
                    object value = Get(cnti);
                    switch (Type.GetTypeCode(value.GetType()))
                    {
                    case TypeCode.Decimal:
                    case TypeCode.Double:
                    case TypeCode.Int16:
                    case TypeCode.Int32:
                    case TypeCode.Int64:
                    case TypeCode.UInt16:
                    case TypeCode.UInt32:
                    case TypeCode.UInt64:
                    case TypeCode.Single:
                        str = string.Format(
                            "{0}\"{1}\":{2}", (cnti > 0 ? ", " : ""),
                            AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                            (Get(cnti) == null ? "" : AZString.Encode(AZString.ENCODE.JSON, value.ToString()))
                            );
                        break;

                    case TypeCode.DBNull:
                        str = string.Format(
                            "{0}\"{1}\":{2}", (cnti > 0 ? ", " : ""),
                            AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                            "null"
                            );
                        break;

                    case TypeCode.Boolean:
                        str = string.Format(
                            "{0}\"{1}\":{2}", (cnti > 0 ? ", " : ""),
                            AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                            ((bool)value) ? "true" : "false"
                            );
                        break;

                    default:
                        str = string.Format(
                            "{0}\"{1}\":\"{2}\"", (cnti > 0 ? ", " : ""),
                            AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                            (Get(cnti) == null ? "" : AZString.Encode(AZString.ENCODE.JSON, value.ToString()))
                            );
                        break;
                    }
                    rtnValue.Append(str);
                }
                return(rtnValue.ToString());
            }
Exemplo n.º 3
0
 /// <summary>key, value 자료를 입력받아 현재의 자료에 추가</summary>
 /// <param name="key">string, key값</param>
 /// <param name="value">object, kye에 해당하는 자료값</param>
 public AZData Add(string key, object value)
 {
     lock (lockObject) {
         if (map_async.ContainsKey(key))
         {
             // 동일 키값이 이미 존재하는 경우
             string linkString = AZString.Random(20);
             map_async.Add(linkString, value);
             indexer.Add(new KeyLink(key, linkString));
         }
         else
         {
             map_async.Add(key, value);
             indexer.Add(new KeyLink(key, key));
         }
     }
     return(this);
 }
Exemplo n.º 4
0
        /// <summary>Get 메소드의 generic 형</summary>
        /// <param name="index">int, 반환할 자료의 index 값, zero base</param>
        public T Get <T>(int index)
        {
            object rtnValue;

            if (typeof(T).Name.Equals(typeof(String).Name))
            {
                rtnValue = "";
            }
            else
            {
                rtnValue = Activator.CreateInstance(typeof(T));
            }
            rtnValue = Get(index);
            if (rtnValue != null)
            {
                try {
                    rtnValue = AZString.Init(rtnValue).To <T>();
                }
                catch (Exception) { }
            }
            return((T)rtnValue);
        }
Exemplo n.º 5
0
 /// <summary>Get(int) 메소드에 대한 long형 변경 처리</summary>
 /// <param name="key">가져올 자료에 대한 key값</param>
 public long GetLong(string key)
 {
     return(AZString.Init(Get(key)).ToLong());
 }
Exemplo n.º 6
0
 /// <summary>Get(int) 메소드에 대한 long형 변경 처리</summary>
 /// <param name="index">가져올 자료에 대한 index값</param>
 /// <param name="defaultValue">내부 오류 발생시 반환할 기본값</param>
 public long GetLong(int index, long defaultValue)
 {
     return(AZString.Init(Get(index)).ToLong(defaultValue));
 }
Exemplo n.º 7
0
 /// <summary>Get(int) 메소드에 대한 long형 변경 처리</summary>
 /// <param name="index">가져올 자료에 대한 index값</param>
 public long GetLong(int index)
 {
     return(AZString.Init(Get(index)).ToLong());
 }
Exemplo n.º 8
0
 /// <summary>Get(int) 메소드에 대한 int형 변경 처리</summary>
 /// <param name="key">가져올 자료에 대한 key값</param>
 /// <param name="defaultValue">내부 오류 발생시 반환할 기본값</param>
 public int GetInt(string key, int defaultValue)
 {
     return(AZString.Init(Get(key)).ToInt(defaultValue));
 }
Exemplo n.º 9
0
 /// <summary>Get(int) 메소드에 대한 float형 변경 처리</summary>
 /// <param name="key">가져올 자료에 대한 key값</param>
 /// <param name="defaultValue">내부 오류 발생시 반환할 기본값</param>
 public float GetFloat(string key, float defaultValue)
 {
     return(AZString.Init(Get(key)).ToFloat(defaultValue));
 }
Exemplo n.º 10
0
 /// <summary>Get(int) 메소드에 대한 float형 변경 처리</summary>
 /// <param name="index">가져올 자료에 대한 index값</param>
 /// <param name="defaultValue">내부 오류 발생시 반환할 기본값</param>
 public float GetFloat(int index, float defaultValue)
 {
     return(AZString.Init(Get(index)).ToFloat(defaultValue));
 }
Exemplo n.º 11
0
 /// <summary>Get(string) 메소드에 대한 문자열 변경 처리</summary>
 /// <param name="key">가져올 자료에 대한 key값</param>
 /// <param name="defaultValue">내부 오류 발생시 반환할 기본값</param>
 public string GetString(string key, string defaultValue)
 {
     return(AZString.Init(Get(key)).String(defaultValue));
 }
Exemplo n.º 12
0
 /// <summary>Get(string) 메소드에 대한 문자열 변경 처리</summary>
 /// <param name="key">가져올 자료에 대한 key값</param>
 public string GetString(string key)
 {
     return(AZString.Init(Get(key)).String());
 }
Exemplo n.º 13
0
 /// <summary>Get(int, string) 메소드에 대한 문자열 변경 처리</summary>
 /// <param name="index">가져올 자료에 대한 index값</param>
 /// <param name="defaultValue">내부 오류 발생시 반환할 기본값</param>
 public string GetString(int index, string defaultValue)
 {
     return(AZString.Init(Get(index)).String(defaultValue));
 }
Exemplo n.º 14
0
 /// <summary>Get(int) 메소드에 대한 문자열 변경 처리</summary>
 /// <param name="index">가져올 자료에 대한 index값</param>
 public string GetString(int index)
 {
     return(AZString.Init(Get(index)).String());
 }
Exemplo n.º 15
0
 /// <summary>Get(int) 메소드에 대한 long형 변경 처리</summary>
 /// <param name="key">가져올 자료에 대한 key값</param>
 /// <param name="defaultValue">내부 오류 발생시 반환할 기본값</param>
 public long GetLong(string key, long defaultValue)
 {
     return(AZString.Init(Get(key)).ToLong(defaultValue));
 }
Exemplo n.º 16
0
 /// <summary>Get(int) 메소드에 대한 float형 변경 처리</summary>
 /// <param name="index">가져올 자료에 대한 index값</param>
 public float GetFloat(int index)
 {
     return(AZString.Init(Get(index)).ToFloat());
 }
Exemplo n.º 17
0
 /// <summary>Get(int) 메소드에 대한 int형 변경 처리</summary>
 /// <param name="index">가져올 자료에 대한 index값</param>
 public int GetInt(int index)
 {
     return(AZString.Init(Get(index)).ToInt());
 }
Exemplo n.º 18
0
 /// <summary>Get(int) 메소드에 대한 float형 변경 처리</summary>
 /// <param name="key">가져올 자료에 대한 key값</param>
 public float GetFloat(string key)
 {
     return(AZString.Init(Get(key)).ToFloat());
 }
Exemplo n.º 19
0
 /// <summary>Get(int) 메소드에 대한 int형 변경 처리</summary>
 /// <param name="index">가져올 자료에 대한 index값</param>
 /// <param name="defaultValue">내부 오류 발생시 반환할 기본값</param>
 public int GetInt(int index, int defaultValue)
 {
     return(AZString.Init(Get(index)).ToInt(defaultValue));
 }
Exemplo n.º 20
0
        /// <summary>ToString에 대한 overriding, JSON형식의 {,} 문자 안쪽의 문자열을 생성</summary>
        override public string ToString()
        {
            StringBuilder builder = new StringBuilder();

            for (int cnti = 0; cnti < indexer.Count; cnti++)
            {
                try {
                    if (Get(cnti) == null)
                    {
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)) + "\"" + ":" + "null");
                    }
                    else if (Get(cnti).GetType().Equals(typeof(AZData)))
                    {
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + GetKey(cnti) + "\"" + ":" + "{" + ((AZData)Get(cnti)).ToString() + "}");
                    }
                    else if (Get(cnti).GetType().Equals(typeof(AZList)))
                    {
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + GetKey(cnti) + "\"" + ":" + "[" + ((AZList)Get(cnti)).ToString() + "]");
                    }
                    else if (Get(cnti).GetType().Equals(typeof(string[])))
                    {
                        string[]      valueSrc = (string[])Get(cnti);
                        StringBuilder sBuilder = new StringBuilder();
                        for (int cntk = 0; cntk < valueSrc.Length; cntk++)
                        {
                            if (valueSrc[cntk] == null)
                            {
                                sBuilder.AppendFormat("{0}null", cntk > 0 ? "," : "");
                            }
                            else
                            {
                                sBuilder.AppendFormat("{0}\"{1}\"", cntk > 0 ? "," : "", AZString.Encode(AZString.ENCODE.JSON, valueSrc[cntk]));
                            }
                        }
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)) + "\"" + ":" + "[" + sBuilder.ToString() + "]");
                    }
                    else if (Get(cnti).GetType().Equals(typeof(int[])))
                    {
                        string valueString = ((int[])Get(cnti)).Join(",");
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)) + "\"" + ":" + "[" + valueString + "]");
                    }
                    else if (Get(cnti).GetType().Equals(typeof(long[])))
                    {
                        string valueString = ((long[])Get(cnti)).Join(",");
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)) + "\"" + ":" + "[" + valueString + "]");
                    }
                    else if (Get(cnti).GetType().Equals(typeof(float[])))
                    {
                        string valueString = ((float[])Get(cnti)).Join(",");
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)) + "\"" + ":" + "[" + valueString + "]");
                    }
                    else if (Get(cnti).GetType().Equals(typeof(double[])))
                    {
                        string valueString = ((double[])Get(cnti)).Join(",");
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)) + "\"" + ":" + "[" + valueString + "]");
                    }
                    else if (Get(cnti).GetType().Equals(typeof(bool[])))
                    {
                        string valueString = ((bool[])Get(cnti)).Join(",");
                        builder.Append((cnti > 0 ? ", " : "") + "\"" + AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)) + "\"" + ":" + "[" + valueString + "]");
                    }
                    else
                    {
                        string str;
                        object value = Get(cnti);
                        switch (Type.GetTypeCode(value.GetType()))
                        {
                        case TypeCode.Decimal: case TypeCode.Double:
                        case TypeCode.Int16:
                        case TypeCode.Int32:
                        case TypeCode.Int64:
                        case TypeCode.UInt16:
                        case TypeCode.UInt32:
                        case TypeCode.UInt64:
                        case TypeCode.Single:
                            str = string.Format(
                                "{0}\"{1}\":{2}", (cnti > 0 ? ", " : ""),
                                AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                                (Get(cnti) == null ? "" : AZString.Encode(AZString.ENCODE.JSON, value.ToString()))
                                );
                            break;

                        case TypeCode.DBNull:
                            str = string.Format(
                                "{0}\"{1}\":{2}", (cnti > 0 ? ", " : ""),
                                AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                                "null"
                                );
                            break;

                        case TypeCode.Boolean:
                            str = string.Format(
                                "{0}\"{1}\":{2}", (cnti > 0 ? ", " : ""),
                                AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                                ((bool)value) ? "true" : "false"
                                );
                            break;

                        case TypeCode.DateTime:
                            str = string.Format(
                                "{0}\"{1}\":\"{2}\"", (cnti > 0 ? ", " : ""),
                                AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                                ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss.fff")
                                );
                            break;

                        default:
                            str = string.Format(
                                "{0}\"{1}\":\"{2}\"", (cnti > 0 ? ", " : ""),
                                AZString.Encode(AZString.ENCODE.JSON, GetKey(cnti)),
                                (Get(cnti) == null ? "" : AZString.Encode(AZString.ENCODE.JSON, value.ToString()))
                                );
                            break;
                        }
                        builder.Append(str);
                    }
                }
                catch (Exception) {
                    builder.Append((cnti > 0 ? ", " : "") + "\"" + GetKey(cnti) + "\"" + ":\"\"");
                }
            }
            return(builder.ToString());
        }
Exemplo n.º 21
0
 /// <summary>Get(int) 메소드에 대한 int형 변경 처리</summary>
 /// <param name="key">가져올 자료에 대한 key값</param>
 public int GetInt(string key)
 {
     return(AZString.Init(Get(key)).ToInt());
 }