예제 #1
0
        public override int InsertOrUpdate <T>(ZLSoft.Pub.StrObjectDict dict)
        {
            DBState state = null;
            T       t     = System.Activator.CreateInstance <T>();

            if (!dict.ContainsKey("ID") || string.IsNullOrEmpty(dict["ID"].ToString()))
            {
                dict["ID"]      = Utils.getGUID();
                dict["RelatID"] = dict["ID"];
                state           = new DBState
                {
                    Name  = t.MAP_INSERT,
                    Param = dict,
                    Type  = ESqlType.INSERT
                };
            }
            else
            {
                state = new DBState
                {
                    Name  = t.MAP_UPDATE,
                    Param = dict,
                    Type  = ESqlType.UPDATE
                };
            }
            return(DB.Execute(state));
        }
예제 #2
0
        public static StrObjectDict Union2 <T>(this IDictionary <string, object> dictionary1, T dictionary2) where T : System.Collections.Generic.IDictionary <string, object>
        {
            StrObjectDict strObjDict = new StrObjectDict();

            foreach (KeyValuePair <string, object> current in dictionary1.Union(dictionary2))
            {
                strObjDict.Add(current.Key, current.Value);
            }
            return(strObjDict);
        }
예제 #3
0
        public static StrObjectDict FindOnlyBy(this IEnumerable <StrObjectDict> objs, string item_name, string value)
        {
            if (objs is List <StrObjectDict> )
            {
                StrObjectDict ll = ((List <StrObjectDict>) objs).Find(delegate(StrObjectDict obj)
                {
                    return("" + obj[item_name] == value || value.Equals(obj[item_name]));
                });
                return(ll);
            }

            return(new StrObjectDict());
        }
예제 #4
0
파일: Utils.cs 프로젝트: LuckyN/hip
        public static string GetString(StrObjectDict dict, string as_str)
        {
            string result;

            if (dict.ContainsKey(as_str))
            {
                result = Utils.GetString(dict[as_str]);
            }
            else
            {
                result = "";
            }
            return(result);
        }
예제 #5
0
        public static StrObjectDict FindOnlyBy(this IEnumerable <StrObjectDict> objs, string[] columns, string[] values)
        {
            if (objs is List <StrObjectDict> )
            {
                string        temp_values = values.ObjectToString();
                StrObjectDict ll          = ((List <StrObjectDict>) objs).Find(delegate(StrObjectDict obj)
                {
                    string temp_values2 = obj.GetValues(columns);
                    return(temp_values == temp_values2);
                });
                return(ll);
            }

            return(new StrObjectDict());
        }
예제 #6
0
        public static StrObjectDict HttpDataToDict(this HttpRequestBase request, bool emptyAsKey)
        {
            //return new StrObjectDict().Merger(request.Form);
            if (request.ContentType.IndexOf("application/json") > -1)
            {
                try
                {
                    StreamReader reader = new StreamReader(request.InputStream, request.ContentEncoding);
                    string       req    = reader.ReadToEnd();
                    object       oi     = JsonAdapter.FromJsonAsDictionary(req);
                    return(StrObjectDict.FromVariable(oi, emptyAsKey));
                }
                catch (Exception)
                {
                    throw;
                }
            }

            var           o   = StrObjectDict.FromVariable(request.Form, emptyAsKey);
            StrObjectDict sod = new StrObjectDict();

            sod.Add("Params", o.Merger(request.QueryString));
            return(sod);
        }
예제 #7
0
 public StrObjectDict(StrObjectDict dictionary)
     : base(dictionary)
 {
 }
예제 #8
0
 public static StrObjectDict FromVariable(object o, bool nullValueAsKey)
 {
     return(StrObjectDict.FromVariable(o, nullValueAsKey, ECase.NORMAL));
 }
예제 #9
0
 public static StrObjectDict FromVariable(object o)
 {
     return(StrObjectDict.FromVariable(o, true));
 }
예제 #10
0
 public static StrObjectDict toStrObjDict(this object o, bool nullValueAsKey)
 {
     //Dictionary<string, object> dictionary = new Dictionary<string, object>();
     //return dictionary.Merger(o, nullValueAsKey) ;
     return(StrObjectDict.FromVariable(o, nullValueAsKey));
 }
예제 #11
0
 public static StrObjectDict toStrObjDict(this object o)
 {
     return(StrObjectDict.FromVariable(o));
 }