Пример #1
0
 private static void FindIndexMethod(GenerateParametersInfo generateParametersInfo, Type type, StringBuilder stringBuilder, string string_2, string string_3)
 {
     MeberOperationHelperContainer class2 = type.GetMeberOperationHelperContainer(false);
     foreach (KeyValuePair<string, MeberOperationHelper> pair in class2.GetDict())
     {
         if (!(pair.Value.GetDbColumnAttribute().IgnoreLoad || pair.Value.GetDbColumnAttribute().HasPrefix))
         {
             stringBuilder.AppendFormat("xx.{0} = FastDBEngine.MyExtensions.FindIndex(cc, \"{1}\");\r\n", generateParametersInfo.NameIndexDict[string_2 + pair.Key], string_3 + pair.Value.GetDbColumnAttribute().Alias);
         }
     }
     foreach (KeyValuePair<string, MeberOperationHelper> pair in class2.GetDict())
     {
         if (!(pair.Value.GetDbColumnAttribute().IgnoreLoad || !pair.Value.GetDbColumnAttribute().HasPrefix))
         {
             FindIndexMethod(generateParametersInfo, pair.Value.GetPropertyType(), stringBuilder, string_2 + pair.Key + string_1, string_3 + pair.Value.GetDbColumnAttribute().SubItemPrefix);
         }
     }
 }
Пример #2
0
 private static void SetGuidMethod(Type type, Dictionary<string, string> dict, string string_2)
 {
     MeberOperationHelperContainer class2 = type.GetMeberOperationHelperContainer(false);
     foreach (KeyValuePair<string, MeberOperationHelper> pair in class2.GetDict())
     {
         if (!(pair.Value.GetDbColumnAttribute().IgnoreLoad || pair.Value.GetDbColumnAttribute().HasPrefix))
         {
             dict[string_2 + pair.Key] = GetGuid();
         }
     }
     foreach (KeyValuePair<string, MeberOperationHelper> pair in class2.GetDict())
     {
         if (!(pair.Value.GetDbColumnAttribute().IgnoreLoad || !pair.Value.GetDbColumnAttribute().HasPrefix))
         {
             SetGuidMethod(pair.Value.GetPropertyType(), dict, string_2 + pair.Key + string_1);
         }
     }
 }
Пример #3
0
 private static void LoadDatarowMethod(GenerateParametersInfo generateParametersInfo, Type type, StringBuilder stringBuilder, string string_2, string string_3)
 {
     MeberOperationHelperContainer meberOperationHelperContainer = type.GetMeberOperationHelperContainer(false);
     foreach (KeyValuePair<string, MeberOperationHelper> pair in meberOperationHelperContainer.GetDict())
     {
         if (!pair.Value.GetDbColumnAttribute().IgnoreLoad && !pair.Value.GetDbColumnAttribute().HasPrefix)
         {
             stringBuilder.AppendFormat("if( xx.{0} >= 0 ) {{\r\n", generateParametersInfo.NameIndexDict[string_2 + pair.Key]);
             if (!(!pair.Value.GetPropertyType().IsValueType || pair.Value.GetPropertyType().IsNullable()))
             {
                 stringBuilder.AppendFormat("{0}{1} = ({2})(row[xx.{3}]);\r\n", new object[] { string_3, pair.Key, pair.Value.GetPropertyType().GetGenericArgumentsString(), generateParametersInfo.NameIndexDict[string_2 + pair.Key] });
             }
             else
             {
                 stringBuilder.AppendFormat("object val = row[xx.{0}];\r\n", generateParametersInfo.NameIndexDict[string_2 + pair.Key]);
                 stringBuilder.AppendLine("if( val != null && DBNull.Value.Equals(val) == false )");
                 stringBuilder.AppendFormat("{0}{1} = ({2})(val);\r\n", string_3, pair.Key, pair.Value.GetPropertyType().IsNullable() ? pair.Value.GetPropertyType().GetFirstGenericArgumentsOrDefault().GetGenericArgumentsString() : pair.Value.GetPropertyType().GetGenericArgumentsString());
             }
             stringBuilder.AppendLine("}");
         }
     }
     foreach (KeyValuePair<string, MeberOperationHelper> pair in meberOperationHelperContainer.GetDict())
     {
         if (!(pair.Value.GetDbColumnAttribute().IgnoreLoad || !pair.Value.GetDbColumnAttribute().HasPrefix))
         {
             stringBuilder.AppendFormat("{0}{1} = new {2}();\r\n", string_3, pair.Key, pair.Value.GetPropertyType().GetGenericArgumentsString());
             LoadDatarowMethod(generateParametersInfo, pair.Value.GetPropertyType(), stringBuilder, string_2 + pair.Key + string_1, string_3 + pair.Key + ".");
         }
     }
 }
Пример #4
0
    private static void GenerateMethodBody(GenerateParametersInfo generateParametersInfo, Type type, StringBuilder stringBuilder, string prefix, string modelName)
    {
        MeberOperationHelperContainer meberOperationHelperContainer = type.GetMeberOperationHelperContainer(false);
        //stringBuilder_0.AppendLine("try");
        //stringBuilder_0.AppendLine("{ ");
        // stringBuilder_0.AppendLine("System.Console.WriteLine(\"111111111111111111111111111\");");
        foreach (KeyValuePair<string, MeberOperationHelper> pair in meberOperationHelperContainer.GetDict())
        {
            //   stringBuilder_0.AppendFormat("System.Console.WriteLine(\"{0}\");\r\n", pair.Key);
            if (!pair.Value.GetDbColumnAttribute().IgnoreLoad && !pair.Value.GetDbColumnAttribute().HasPrefix)
            {
                stringBuilder.AppendFormat("if( xx.{0} >= 0 ) {{\r\n", generateParametersInfo.NameIndexDict[prefix + pair.Key]);
                if (pair.Value.GetPropertyType() == TypeInfo.TypeChar)
                {
                    stringBuilder.AppendFormat("{0}{1} = reader.GetString(xx.{2})[0];\r\n", modelName, pair.Key, generateParametersInfo.NameIndexDict[prefix + pair.Key]);
                }
                else if (pair.Value.GetPropertyType() == typeof(char?))
                {
                    stringBuilder.AppendFormat("object val = reader.GetValue(xx.{0});\r\n", generateParametersInfo.NameIndexDict[prefix + pair.Key]);
                    stringBuilder.AppendLine("if( val != null && DBNull.Value.Equals(val) == false ) {");
                    stringBuilder.AppendLine("string str = val.ToString();");
                    stringBuilder.AppendLine("if( str.Length > 0 ) ");
                    stringBuilder.AppendFormat("{0}{1} = str[0];\r\n", modelName, pair.Key);
                    stringBuilder.AppendLine("}");
                }
                else if (!(!pair.Value.GetPropertyType().IsValueType || pair.Value.GetPropertyType().IsNullable()))
                {
                    if (!pair.Value.GetPropertyType().FullName.Contains("System.Int32"))
                        stringBuilder.AppendFormat("{0}{1} = {2}(xx.{3});\r\n", new object[] { modelName, pair.Key, GetReaderStr(pair.Value), generateParametersInfo.NameIndexDict[prefix + pair.Key] });
                    else
                        stringBuilder.AppendFormat("{0}{1} =Convert.ToInt32(reader.GetDecimal(xx.{2}));\r\n", new object[] { modelName, pair.Key, generateParametersInfo.NameIndexDict[prefix + pair.Key] });//, GetReaderStr(pair.Value)
                }
                else
                {
                    stringBuilder.AppendFormat("object val = reader.GetValue(xx.{0});\r\n", generateParametersInfo.NameIndexDict[prefix + pair.Key]);
                    stringBuilder.AppendLine("if( val != null && DBNull.Value.Equals(val) == false )");
                    if (!pair.Value.GetPropertyType().FullName.Contains("System.Int32"))
                        stringBuilder.AppendFormat("{0}{1} = ({2})(val);\r\n", modelName, pair.Key, pair.Value.GetPropertyType().IsNullable() ? pair.Value.GetPropertyType().GetFirstGenericArgumentsOrDefault().GetGenericArgumentsString() : pair.Value.GetPropertyType().GetGenericArgumentsString());
                    else
                        stringBuilder.AppendFormat("{0}{1} = Convert.ToInt32((val));\r\n", modelName, pair.Key);//, pair.Value.method_3().IsNullable() ? pair.Value.method_3().smethod_3().smethod_7() : pair.Value.method_3().smethod_7());
                }
                stringBuilder.AppendLine("}");
            }
        }
        //stringBuilder_0.AppendLine(" } ");
        //stringBuilder_0.AppendLine("catch(Exception ex) { ");
        //stringBuilder_0.AppendLine(" System.Diagnostics.Trace.WriteLine(ex.StackTrace);");
        //stringBuilder_0.AppendLine(" } ");

        foreach (KeyValuePair<string, MeberOperationHelper> pair in meberOperationHelperContainer.GetDict())
        {
            if (!(pair.Value.GetDbColumnAttribute().IgnoreLoad || !pair.Value.GetDbColumnAttribute().HasPrefix))
            {
                stringBuilder.AppendFormat("{0}{1} = new {2}();\r\n", modelName, pair.Key, pair.Value.GetPropertyType().GetGenericArgumentsString());
                GenerateMethodBody(generateParametersInfo, pair.Value.GetPropertyType(), stringBuilder, prefix + pair.Key + string_1, modelName + pair.Key + ".");
            }
        }
    }