Exemplo n.º 1
0
 public static void LoadInfoFromParameterList(object targetObject, List <Parameter> parameterList)
 {
     parameterList.ForEach(v =>
     {
         var f = targetObject.GetType().GetProperty(v.Name);
         if (f != null && f.CanWrite)
         {
             CommonProc.SetProperty(targetObject, f, v.Value);
         }
     });
 }
Exemplo n.º 2
0
 static string GetDefaultMemo(Parameter p)
 {
     try
     {
         string s = "";
         if (p == null || p.Value == null)
         {
             return(s);
         }
         if (p.Value.GetType() == typeof(int))
         {
             s = int.MinValue.ToString() + "-" + int.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(short))
         {
             s = short.MinValue.ToString() + "-" + short.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(long))
         {
             s = long.MinValue.ToString() + "-" + long.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(byte))
         {
             s = byte.MinValue.ToString() + "-" + byte.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(uint))
         {
             s = uint.MinValue.ToString() + "-" + uint.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(ushort))
         {
             s = ushort.MinValue.ToString() + "-" + ushort.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(ulong))
         {
             s = ulong.MinValue.ToString() + "-" + ulong.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(sbyte))
         {
             s = sbyte.MinValue.ToString() + "-" + sbyte.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(double))
         {
             s = double.MinValue.ToString() + "-" + double.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(float))
         {
             s = float.MinValue.ToString() + "-" + float.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(decimal))
         {
             s = decimal.MinValue.ToString() + "-" + decimal.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(DateTime))
         {
             s = DateTime.MinValue.ToString() + "-" + DateTime.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType() == typeof(bool))
         {
             s = "True or False,";
         }
         else if (p.Value.GetType() == typeof(char))
         {
             s = char.MinValue.ToString() + "-" + char.MinValue.ToString() + ",";
         }
         else if (p.Value.GetType().IsSubclassOf(typeof(Enum)))
         {
             s = CommonProc.GetListString <string>(Enum.GetNames(p.Value.GetType()).ToList()) + ",";
         }
         else if (p.Value is string)
         {
             if (string.IsNullOrEmpty(p.Value.ToString().Trim()))
             {
                 return("");
             }
         }
         s += " default is " + p.DefaultValue;
         return(s);
     }
     catch (Exception ex)
     {
         LogSupport.Error(ex);
         return("");
     }
 }