コード例 #1
0
ファイル: Verifyer.cs プロジェクト: zlzforever/AutoCSer
            /// <summary>
            /// 获取列名集合
            /// </summary>
            /// <param name="name">列名前缀</param>
            /// <returns></returns>
            internal static string[] GetColumnNames(string name)
            {
                string[]   names;
                HashString nameKey = name;

                if (columnNames.TryGetValue(ref nameKey, out names))
                {
                    return(names);
                }
                LeftArray <string> nameList = new LeftArray <string>(verifyFields.Length);

                foreach (Field field in verifyFields)
                {
                    if (field.IsSqlColumn)
                    {
                        ColumnGroup.Verifyer.GetColumnNames(field.FieldInfo.FieldType)(ref nameList, name + "_" + field.FieldInfo.Name);
                    }
                    else
                    {
                        nameList.Add(name + "_" + field.FieldInfo.Name);
                    }
                }
                columnNames.Set(ref nameKey, names = nameList.ToArray());
                return(names);
            }
コード例 #2
0
 /// <summary>
 /// 根据连接类型获取连接信息
 /// </summary>
 /// <param name="type">连接类型</param>
 /// <returns>连接信息</returns>
 internal static Connection GetConnection(string type)
 {
     if (type != null)
     {
         Connection value;
         HashString key = type;
         if (!connections.TryGetValue(ref key, out value))
         {
             connections.Set(ref key, value = ConfigLoader.GetUnion(typeof(Connection), type).Connection ?? new Connection());
         }
         return(value);
     }
     return(null);
 }
コード例 #3
0
        /// <summary>
        /// 获取泛型类型元数据
        /// </summary>
        /// <param name="type1"></param>
        /// <param name="type2"></param>
        /// <returns></returns>
        public static ParameterGenericType2 Get(Type type1, Type type2)
        {
            ParameterGenericType2 value;

            AutoCSer.Metadata.GenericType2.TypeKey typeKey = new AutoCSer.Metadata.GenericType2.TypeKey {
                Type1 = type1, Type2 = type2
            };
            if (!cache.TryGetValue(ref typeKey, out value))
            {
                value = new UnionType {
                    Value = createMethod.MakeGenericMethod(type1, type2).Invoke(null, null)
                }.ParameterGenericType2;
                cache.Set(ref typeKey, value);
            }
            return(value);
        }
コード例 #4
0
        /// <summary>
        /// 获取泛型类型元数据
        /// </summary>
        /// <param name="type1"></param>
        /// <param name="type2"></param>
        /// <returns></returns>
        public static CollectionGenericType2 Get(Type type1, Type type2)
        {
            CollectionGenericType2 value;

            GenericType2.TypeKey typeKey = new GenericType2.TypeKey {
                Type1 = type1, Type2 = type2
            };
            if (!cache.TryGetValue(ref typeKey, out value))
            {
                value = new UnionType {
                    Value = createMethod.MakeGenericMethod(type1, type2).Invoke(null, null)
                }.CollectionGenericType2;
                cache.Set(ref typeKey, value);
            }
            return(value);
        }
コード例 #5
0
 /// <summary>
 /// 获取列名集合
 /// </summary>
 /// <param name="name">列名前缀</param>
 /// <returns></returns>
 public unsafe static string GetColumnNames(string name)
 {
     if (custom != null)
     {
         return(custom.GetColumnNames(name));
     }
     if (columnNames != null)
     {
         string     names;
         HashString nameKey = name;
         if (columnNames.TryGetValue(ref nameKey, out names))
         {
             return(names);
         }
         int   isNext = 0;
         byte *buffer = UnmanagedPool.Default.Get();
         try
         {
             using (CharStream sqlStream = new CharStream((char *)buffer, UnmanagedPool.DefaultSize >> 1))
             {
                 foreach (Field field in Fields)
                 {
                     if (field.IsSqlColumn)
                     {
                         if ((names = ColumnGroup.Inserter.GetColumnNames(field.FieldInfo.FieldType)(name + "_" + field.FieldInfo.Name)) != null)
                         {
                             if (isNext == 0)
                             {
                                 isNext = 1;
                             }
                             else
                             {
                                 sqlStream.Write(',');
                             }
                             sqlStream.Write(names);
                         }
                     }
                     else
                     {
                         if (isNext == 0)
                         {
                             isNext = 1;
                         }
                         else
                         {
                             sqlStream.Write(',');
                         }
                         sqlStream.PrepLength(name.Length + field.FieldInfo.Name.Length + 1);
                         sqlStream.SimpleWriteNotNull(name);
                         sqlStream.Write('_');
                         sqlStream.SimpleWriteNotNull(field.FieldInfo.Name);
                     }
                 }
                 names = sqlStream.Length == 0 ? null : sqlStream.ToString();
                 columnNames.Set(ref nameKey, names);
             }
         }
         finally { UnmanagedPool.Default.Push(buffer); }
         return(names);
     }
     return(null);
 }