Ejemplo n.º 1
0
 public void TestExpandoPorpertyGetter()
 {
     var expGetter = new ExpandoPorpertyGetter();
     dynamic tester = new ExpandoObject();
     tester.ID = "id";
     tester.T2 = "t2";
     IDictionary<string,object> retDic = expGetter.GetPropertyDic(tester);
     Assert.AreEqual(retDic.Keys.Count, 2);
 }
Ejemplo n.º 2
0
        private string GenExpandoUpdateParaString(ExpandoObject obj)
        {
            var ret     = new StringBuilder();
            var i       = 1;
            var pg      = new Utility.ExpandoPorpertyGetter();
            var paraDic = pg.GetPropertyDic(obj);

            foreach (var key in paraDic.Keys)
            {
                ret.Append(" " + key + "=@" + key + " ");
                if (i < paraDic.Keys.Count)
                {
                    ret.Append(" , ");
                    i++;
                }
            }
            return(ret.ToString());
        }
Ejemplo n.º 3
0
        private void setProValueToDynPara(DynamicParameters dp, Object o)
        {
            Type type = o.GetType();

            if (type.Equals(typeof(ExpandoObject)))
            {
                var pg      = new Utility.ExpandoPorpertyGetter();
                var paraDic = pg.GetPropertyDic(o);
                foreach (var key in paraDic.Keys)
                {
                    dp.Add("@" + key, paraDic[key]);
                }
            }
            else
            {
                IList <PropertyInfo> props = new List <PropertyInfo>(type.GetProperties());
                foreach (PropertyInfo prop in props)
                {
                    object propValue = prop.GetValue(o, null);
                    dp.Add("@" + prop.Name, propValue);
                }
            }
        }