Example #1
0
 /// <summary>
 /// 常量转换
 /// </summary>
 protected constantConverter()
 {
     list<keyValue<hashCode<Type>, func<object, string>>> values = new list<keyValue<hashCode<Type>, func<object, string>>>();
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(bool), convertConstantBoolTo01));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(bool?), convertConstantBoolNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(byte), convertConstantByte));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(byte?), convertConstantByteNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(sbyte), convertConstantSByte));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(sbyte?), convertConstantSByteNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(short), convertConstantShort));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(short?), convertConstantShortNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ushort), convertConstantUShort));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ushort?), convertConstantUShortNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(int), convertConstantInt));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(int?), convertConstantIntNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(uint), convertConstantUInt));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(uint?), convertConstantUIntNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(long), convertConstantLong));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(long?), convertConstantLongNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ulong), convertConstantULong));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ulong?), convertConstantULongNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(float), convertConstantFloat));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(float?), convertConstantFloatNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(double), convertConstantDouble));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(double?), convertConstantDoubleNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(decimal), convertConstantDecimal));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(decimal?), convertConstantDecimalNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(DateTime), convertConstantDateTimeMillisecond));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(DateTime?), convertConstantDateTimeMillisecondNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(string), null));
     converters = new staticDictionary<hashCode<Type>, func<object, string>>(values);
 }
Example #2
0
 static type()
 {
     #region 初始化 类型名称集合
     keyValue <hashCode <Type>, string>[] types = new keyValue <hashCode <Type>, string>[]
     {
         new keyValue <hashCode <Type>, string>(typeof(bool), "bool"),
         new keyValue <hashCode <Type>, string>(typeof(byte), "byte"),
         new keyValue <hashCode <Type>, string>(typeof(sbyte), "sbyte"),
         new keyValue <hashCode <Type>, string>(typeof(short), "short"),
         new keyValue <hashCode <Type>, string>(typeof(ushort), "ushort"),
         new keyValue <hashCode <Type>, string>(typeof(int), "int"),
         new keyValue <hashCode <Type>, string>(typeof(uint), "uint"),
         new keyValue <hashCode <Type>, string>(typeof(long), "long"),
         new keyValue <hashCode <Type>, string>(typeof(ulong), "ulong"),
         new keyValue <hashCode <Type>, string>(typeof(float), "float"),
         new keyValue <hashCode <Type>, string>(typeof(double), "double"),
         new keyValue <hashCode <Type>, string>(typeof(decimal), "decimal"),
         new keyValue <hashCode <Type>, string>(typeof(char), "char"),
         new keyValue <hashCode <Type>, string>(typeof(string), "string"),
         new keyValue <hashCode <Type>, string>(typeof(object), "object"),
         new keyValue <hashCode <Type>, string>(typeof(void), "void")
     };
     typeNames = new staticDictionary <hashCode <Type>, string>(types);
     #endregion
 }
        /// <summary>
        /// 常量转换
        /// </summary>
        protected constantConverter()
        {
            list <keyValue <hashCode <Type>, func <object, string> > > values = new list <keyValue <hashCode <Type>, func <object, string> > >();

            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(bool), convertConstantBoolTo01));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(bool?), convertConstantBoolNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(byte), convertConstantByte));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(byte?), convertConstantByteNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(sbyte), convertConstantSByte));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(sbyte?), convertConstantSByteNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(short), convertConstantShort));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(short?), convertConstantShortNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(ushort), convertConstantUShort));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(ushort?), convertConstantUShortNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(int), convertConstantInt));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(int?), convertConstantIntNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(uint), convertConstantUInt));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(uint?), convertConstantUIntNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(long), convertConstantLong));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(long?), convertConstantLongNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(ulong), convertConstantULong));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(ulong?), convertConstantULongNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(float), convertConstantFloat));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(float?), convertConstantFloatNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(double), convertConstantDouble));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(double?), convertConstantDoubleNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(decimal), convertConstantDecimal));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(decimal?), convertConstantDecimalNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(DateTime), convertConstantDateTimeMillisecond));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(DateTime?), convertConstantDateTimeMillisecondNullable));
            values.Add(new keyValue <hashCode <Type>, func <object, string> >(typeof(string), null));
            converters = new staticDictionary <hashCode <Type>, func <object, string> >(values);
        }
Example #4
0
        /// <summary>
        /// 转换器
        /// </summary>
        /// <param name="expression">委托关联表达式</param>
        /// <param name="nameType">获取参数名称方式</param>
        protected converter(LambdaExpression expression, getNameType nameType)
        {
            this.expression = expression;
            this.nameType   = nameType;
            int parameterCount = expression.Parameters.length();

            switch (nameType)
            {
            case getNameType.Parameter:
            case getNameType.Entity:
                if (parameterCount == 0)
                {
                    this.nameType = getNameType.None;
                }
                else if (parameterCount == 1)
                {
                    name = getName(expression.Parameters[0]);
                }
                else
                {
                    names = new staticDictionary <string, string>(expression.Parameters.getArray(parameter => new keyValue <string, string>(parameter.Name, getName(parameter))));
                }
                break;

            default:
                if (parameterCount > 1)
                {
                    fastCSharp.log.Default.Add("不止一个参数 " + parameterCount.toString(), true, true);
                    nameType = getNameType.Entity;
                }
                break;
            }
        }
Example #5
0
 static http()
 {
     #region 初始化查询模式集合
     keyValue <string, methodType>[] types = System.Enum.GetValues(typeof(methodType))
                                             .toArray <methodType>().getFind(value => value != methodType.None)
                                             .GetArray(value => new keyValue <string, methodType>(value.ToString(), value));
     methodTypes     = new staticDictionary <string, methodType>(types);
     methodBytes     = new staticDictionary <hashBytes, methodType>(types.getArray(value => new keyValue <hashBytes, methodType>(value.Key.getBytes(), value.Value)));
     MaxMethodLength = methodTypes.Keys.maxKey(value => value.Length, 0);
     #endregion
 }
Example #6
0
 static http()
 {
     #region 初始化查询模式集合
     keyValue<string, methodType>[] types = System.Enum.GetValues(typeof(methodType))
         .toArray<methodType>().getFind(value => value != methodType.None)
         .GetArray(value => new keyValue<string, methodType>(value.ToString(), value));
     methodTypes = new staticDictionary<string, methodType>(types);
     methodBytes = new staticDictionary<hashBytes, methodType>(types.getArray(value => new keyValue<hashBytes, methodType>(value.Key.getBytes(), value.Value)));
     MaxMethodLength = methodTypes.Keys.maxKey(value => value.Length, 0);
     #endregion
 }
Example #7
0
        static converter()
        {
            list <keyValue <hashCode <Type>, func <object, object> > > getConvertibleList = new list <keyValue <hashCode <Type>, func <object, object> > >();

            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(bool), getBool));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(byte), getByte));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(char), getChar));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(DateTime), getDateTime));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(decimal), getDecimal));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(double), getDouble));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(short), getShort));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(int), getInt));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(long), getLong));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(sbyte), getSByte));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(float), getFloat));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(string), getString));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(ushort), getUShort));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(uint), getUInt));
            getConvertibleList.Add(new keyValue <hashCode <Type>, func <object, object> >(typeof(ulong), getULong));
            getConvertibles = new staticDictionary <hashCode <Type>, func <object, object> >(getConvertibleList);

            Dictionary <string, MethodInfo> methods = typeof(converter).GetMethods(BindingFlags.Static | BindingFlags.NonPublic).getDictionary(value => value.Name);

            getBaseMethodInfo        = methods["getBase"];
            getMethodInfo            = methods["get"];
            getConvertibleMethodInfo = methods["getConvertible"];
            getEnumMethodInfo        = methods["getEnum"];

            list <keyValue <hashCode <Type>, MethodInfo> > getEnumMethodList = new list <keyValue <hashCode <Type>, MethodInfo> >();

            getEnumMethodList.Add(new keyValue <hashCode <Type>, MethodInfo>(typeof(byte), methods["getEnumByte"]));
            getEnumMethodList.Add(new keyValue <hashCode <Type>, MethodInfo>(typeof(sbyte), methods["getEnumSByte"]));
            getEnumMethodList.Add(new keyValue <hashCode <Type>, MethodInfo>(typeof(short), methods["getEnumShort"]));
            getEnumMethodList.Add(new keyValue <hashCode <Type>, MethodInfo>(typeof(ushort), methods["getEnumUShort"]));
            getEnumMethodList.Add(new keyValue <hashCode <Type>, MethodInfo>(typeof(int), methods["getEnumInt"]));
            getEnumMethodList.Add(new keyValue <hashCode <Type>, MethodInfo>(typeof(uint), methods["getEnumUInt"]));
            getEnumMethodList.Add(new keyValue <hashCode <Type>, MethodInfo>(typeof(long), methods["getEnumLong"]));
            getEnumMethodList.Add(new keyValue <hashCode <Type>, MethodInfo>(typeof(ulong), methods["getEnumULong"]));
            getEnumMethods = new staticDictionary <hashCode <Type>, MethodInfo>(getEnumMethodList);
        }
Example #8
0
        /// <summary>
        /// 检测SQL表格
        /// </summary>
        /// <param name="table">SQL表格</param>
        private static void checkSqlTable(keyValue <Type, keyValue <Type, sqlTable> > table)
        {
            table  memberTable = setup.cSharp.sqlTable.cSharp.GetTable(table.Key, table.Value.Value, setup.cSharp.sqlTable.cSharp.GetMembers(table.Value.Key, table.Value.Value));
            client sqlClient   = GetConnection(table.Value.Value.ConnectionType).Client;
            table  sqlTable    = sqlClient.GetTable(memberTable.Columns.Name);

            if (sqlTable == null)
            {
                if (!sqlClient.CreateTable(memberTable))
                {
                    fastCSharp.log.Default.Real("表格 " + memberTable.Columns.Name + " 创建失败", false, false);
                }
            }
            else
            {
                staticDictionary <string, column> sqlColumnNames = new staticDictionary <string, column>(sqlTable.Columns.Columns, value => value.Name);
                list <column> newColumns = memberTable.Columns.Columns.getFind(value => !sqlColumnNames.ContainsKey(value.Name));
                if (newColumns.count() != 0)
                {
                    if (sqlClient.AddFields(new columnCollection {
                        Name = memberTable.Columns.Name, Columns = newColumns.toArray()
                    }))
                    {
                        sqlTable.Columns.Columns = newColumns.add(sqlTable.Columns.Columns).toArray();
                    }
                    else
                    {
                        fastCSharp.log.Default.Real("表格 " + memberTable.Columns.Name + " 字段添加失败 : " + newColumns.joinString(',', value => value.Name), false, false);
                    }
                }
                newColumns = memberTable.Columns.Columns.getFind(value => !value.IsMatch(sqlColumnNames.Get(value.Name, null)));
                if (newColumns.count() != 0)
                {
                    fastCSharp.log.Default.Real("表格 " + memberTable.Columns.Name + " 字段类型不匹配 : " + newColumns.joinString(',', value => value.Name), false, false);
                }
            }
        }
Example #9
0
        unsafe static sqlDbType()
        {
            #region C#类型转SQL数据类型集合
            list <keyValue <hashCode <Type>, SqlDbType> > formCSharpType = new list <keyValue <hashCode <Type>, SqlDbType> >();
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(bool), SqlDbType.Bit));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(byte), SqlDbType.TinyInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(sbyte), SqlDbType.TinyInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(short), SqlDbType.SmallInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(ushort), SqlDbType.SmallInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(int), SqlDbType.Int));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(uint), SqlDbType.Int));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(long), SqlDbType.BigInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(ulong), SqlDbType.BigInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(decimal), SqlDbType.Decimal));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(float), SqlDbType.Real));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(double), SqlDbType.Float));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(string), SqlDbType.NVarChar));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(DateTime), SqlDbType.DateTime));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(Guid), SqlDbType.UniqueIdentifier));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(byte[]), SqlDbType.VarBinary));
            formCSharpTypes = new staticDictionary <hashCode <Type>, SqlDbType>(formCSharpType);
            #endregion

            MaxEnumValue = fastCSharp.Enum.GetMaxValue <SqlDbType>(-1) + 1;
            int       dataIndex = 0, mapSize = ((MaxEnumValue + 31) >> 5) << 2;
            pointer[] datas = unmanaged.Get(true, mapSize, mapSize, MaxEnumValue * sizeof(int));
            stringTypeMap    = new fixedMap(datas[dataIndex++]).Unsafer;
            textImageTypeMap = new fixedMap(datas[dataIndex++]).Unsafer;
            sizes            = datas[dataIndex++];

            #region 字符串类型占位集合
            stringTypeMap.Set((int)SqlDbType.Char);
            stringTypeMap.Set((int)SqlDbType.NChar);
            stringTypeMap.Set((int)SqlDbType.VarChar);
            stringTypeMap.Set((int)SqlDbType.NVarChar);
            stringTypeMap.Set((int)SqlDbType.Text);
            stringTypeMap.Set((int)SqlDbType.NText);
            #endregion

            #region 文本类型占位集合
            textImageTypeMap.Set((int)SqlDbType.Text);
            textImageTypeMap.Set((int)SqlDbType.NText);
            textImageTypeMap.Set((int)SqlDbType.Image);
            #endregion

            #region 类型默认长度
            int *sizeData = sizes.Int;
            for (int i = 0; i != MaxEnumValue; i++)
            {
                sizeData[i] = UnknownSize;
            }
            sizeData[(int)SqlDbType.BigInt] = sizeof(long);
            sizeData[(int)SqlDbType.Binary] = 8000;
            sizeData[(int)SqlDbType.Bit]    = sizeof(bool);
            sizeData[(int)SqlDbType.Char]   = 8000;
            //TypeSize[(int)SqlDbType.Date] = sizeof(long);
            sizeData[(int)SqlDbType.DateTime] = sizeof(long);
            //TypeSize[(int)SqlDbType.DateTime2] = sizeof(long);
            //TypeSize[(int)SqlDbType.DateTimeOffset] = sizeof(long);
            sizeData[(int)SqlDbType.Decimal] = sizeof(decimal);
            sizeData[(int)SqlDbType.Float]   = sizeof(double);
            sizeData[(int)SqlDbType.Image]   = int.MaxValue;
            sizeData[(int)SqlDbType.Int]     = sizeof(int);
            sizeData[(int)SqlDbType.Money]   = sizeof(decimal);
            //TypeSize[(int)SqlDbType.NChar] = MaxStringSize;
            sizeData[(int)SqlDbType.NText] = int.MaxValue;
            //TypeSize[(int)SqlDbType.NVarChar] = MaxStringSize;
            sizeData[(int)SqlDbType.Real]             = sizeof(float);
            sizeData[(int)SqlDbType.UniqueIdentifier] = 8;
            sizeData[(int)SqlDbType.SmallDateTime]    = sizeof(long);
            sizeData[(int)SqlDbType.SmallInt]         = sizeof(short);
            sizeData[(int)SqlDbType.SmallMoney]       = sizeof(decimal);
            sizeData[(int)SqlDbType.Text]             = int.MaxValue;
            //TypeSize[(int)SqlDbType.Time] = 8;
            sizeData[(int)SqlDbType.Timestamp] = 8;
            sizeData[(int)SqlDbType.TinyInt]   = sizeof(byte);
            sizeData[(int)SqlDbType.VarBinary] = 8000;
            sizeData[(int)SqlDbType.VarChar]   = 8000;
            //TypeSize[(int)SqlDbType.Xml] = -1;
            #endregion
        }
Example #10
0
 /// <summary>
 /// 检测SQL表格
 /// </summary>
 /// <param name="table">SQL表格</param>
 private static void checkSqlTable(keyValue<Type, keyValue<Type, sqlTable>> table)
 {
     table memberTable = setup.cSharp.sqlTable.cSharp.GetTable(table.Key, table.Value.Value, setup.cSharp.sqlTable.cSharp.GetMembers(table.Value.Key, table.Value.Value));
     client sqlClient = GetConnection(table.Value.Value.ConnectionType).Client;
     table sqlTable = sqlClient.GetTable(memberTable.Columns.Name);
     if (sqlTable == null)
     {
         if (!sqlClient.CreateTable(memberTable)) fastCSharp.log.Default.Real("表格 " + memberTable.Columns.Name + " 创建失败", false, false);
     }
     else
     {
         staticDictionary<string, column> sqlColumnNames = new staticDictionary<string, column>(sqlTable.Columns.Columns, value => value.Name);
         list<column> newColumns = memberTable.Columns.Columns.getFind(value => !sqlColumnNames.ContainsKey(value.Name));
         if (newColumns.count() != 0)
         {
             if (sqlClient.AddFields(new columnCollection { Name = memberTable.Columns.Name, Columns = newColumns.toArray() }))
             {
                 sqlTable.Columns.Columns = newColumns.add(sqlTable.Columns.Columns).toArray();
             }
             else
             {
                 fastCSharp.log.Default.Real("表格 " + memberTable.Columns.Name + " 字段添加失败 : " + newColumns.joinString(',', value => value.Name), false, false);
             }
         }
         newColumns = memberTable.Columns.Columns.getFind(value => !value.IsMatch(sqlColumnNames.Get(value.Name, null)));
         if (newColumns.count() != 0)
         {
             fastCSharp.log.Default.Real("表格 " + memberTable.Columns.Name + " 字段类型不匹配 : " + newColumns.joinString(',', value => value.Name), false, false);
         }
     }
 }
Example #11
0
 static htmlNode()
 {
     int dataIndex = 0;
     pointer[] datas = unmanaged.Get(true
         , String.asciiMap.mapBytes, String.asciiMap.mapBytes, String.asciiMap.mapBytes
         , String.asciiMap.mapBytes, String.asciiMap.mapBytes, String.asciiMap.mapBytes);
     spaceMap = new String.asciiMap(datas[dataIndex++], "\t\r\n ", true);
     spaceSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n >", true).Pointer;
     tagNameSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n \"'/=>", true).Pointer;
     attributeSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n \"'/=", true).Pointer;
     attributeNameSplitMap = new String.asciiMap(datas[dataIndex++], "\"'/>", true).Pointer;
     String.asciiMap tagNameAsciiMap = new String.asciiMap(tagNameMap = datas[dataIndex++], "!/", true);
     tagNameAsciiMap.Unsafer.Set('a', 26);
     tagNameAsciiMap.Unsafer.Set('A', 26);
     noLowerAttributeNames = new staticDictionary<string, string>(new string[] { "readOnly", "className" }, value => value.ToLower());
 }
Example #12
0
 /// <summary>
 /// 转换器
 /// </summary>
 /// <param name="expression">委托关联表达式</param>
 /// <param name="nameType">获取参数名称方式</param>
 protected converter(LambdaExpression expression, getNameType nameType)
 {
     this.expression = expression;
     this.nameType = nameType;
     int parameterCount = expression.Parameters.length();
     switch (nameType)
     {
         case getNameType.Parameter:
         case getNameType.Entity:
             if (parameterCount == 0) this.nameType = getNameType.None;
             else if (parameterCount == 1) name = getName(expression.Parameters[0]);
             else names = new staticDictionary<string, string>(expression.Parameters.getArray(parameter => new keyValue<string, string>(parameter.Name, getName(parameter))));
             break;
         default:
             if (parameterCount > 1)
             {
                 fastCSharp.log.Default.Add("不止一个参数 " + parameterCount.toString(), true, true);
                 nameType = getNameType.Entity;
             }
             break;
     }
 }
Example #13
0
                /// <summary>
                /// 检测方法序号
                /// </summary>
                /// <param name="methodIndexs">方法集合</param>
                /// <param name="rememberIdentityCommand">命令序号记忆数据</param>
                /// <param name="getMethodKeyName">获取命令名称的委托</param>
                /// <param name="nullMethod">空方法索引信息</param>
                /// <returns>方法集合,失败返回null</returns>
                public static methodIndex[] CheckIdentity(methodIndex[] methodIndexs, staticDictionary <string, int> rememberIdentityCommand, Func <methodIndex, string> getMethodKeyName)
                {
                    if (!rememberIdentityCommand.IsEmpty())
                    {
                        foreach (methodIndex method in methodIndexs)
                        {
                            if (method.Attribute.CommandIentity == int.MaxValue)
                            {
                                int identity = rememberIdentityCommand.Get(getMethodKeyName(method), int.MaxValue);
                                if (identity != int.MaxValue)
                                {
                                    method.Attribute.CommandIentity = identity;
                                }
                            }
                        }
                    }
                    methodIndex[] setMethodIndexs = methodIndexs.getFindArray(value => value.Attribute.CommandIentity != int.MaxValue);
                    int           count           = 0;

                    foreach (methodIndex method in setMethodIndexs)
                    {
                        int identity = method.Attribute.CommandIentity;
                        if (identity != int.MaxValue && identity > count)
                        {
                            count = identity;
                        }
                    }
                    if (++count < methodIndexs.Length)
                    {
                        count = methodIndexs.Length;
                    }
                    methodIndex[] sortMethodIndexs = new methodIndex[count];
                    foreach (methodIndex method in setMethodIndexs)
                    {
                        int identity = method.Attribute.CommandIentity;
                        if (sortMethodIndexs[identity] == null)
                        {
                            sortMethodIndexs[identity] = method;
                        }
                        else
                        {
                            error.Add(method.MethodType.FullName + " 命令序号重复 " + method.MemberFullName + "[" + identity.toString() + "]" + sortMethodIndexs[identity].MemberFullName);
                            return(null);
                        }
                    }
                    count = 0;
                    foreach (methodIndex method in methodIndexs.getFind(value => value.Attribute.CommandIentity == int.MaxValue))
                    {
                        while (sortMethodIndexs[count] != null)
                        {
                            ++count;
                        }
                        (sortMethodIndexs[count] = method).Attribute.CommandIentity = count;
                        ++count;
                    }
                    while (count != sortMethodIndexs.Length)
                    {
                        if (sortMethodIndexs[count] == null)
                        {
                            sortMethodIndexs[count] = nullMethod;
                        }
                        ++count;
                    }
                    return(sortMethodIndexs);
                    //methodIndexs = methodIndexs.getSort(value => value.Attribute.CommandIentity);
                    //for (int index = 0; index != methodIndexs.Length; ++index)
                    //{
                    //    methodIndex method = methodIndexs[index];
                    //    int identity = method.Attribute.CommandIentity;
                    //    while (identity != index)
                    //    {
                    //        if (identity == int.MaxValue)
                    //        {
                    //            methodIndexs[index] = method;
                    //            method.CopyTypeAttribute.CommandIentity = identity = index;
                    //        }
                    //        else if (identity < methodIndexs.Length)
                    //        {
                    //            methodIndex moveMethod = methodIndexs[identity];
                    //            int moveIdentity = moveMethod.Attribute.CommandIentity;
                    //            if (moveIdentity == identity)
                    //            {
                    //                error.Add(method.MethodType.FullName + " 命令序号重复 " + method.Method.Method.Name + "[" + identity.toString() + "]" + moveMethod.Method.Method.Name);
                    //                return null;
                    //            }
                    //            methodIndexs[identity] = method;
                    //            identity = moveIdentity;
                    //            method = moveMethod;
                    //        }
                    //        else
                    //        {
                    //            error.Add(method.MethodType.FullName + " 命令序号错误 " + method.Method.Method.Name + "[" + identity.toString() + "] >= " + methodIndexs.Length.toString());
                    //            return null;
                    //        }
                    //    }
                    //}
                    //return methodIndexs;
                }
Example #14
0
        unsafe static sqlDbType()
        {
            #region C#类型转SQL数据类型集合
            list<keyValue<hashCode<Type>, SqlDbType>> formCSharpType = new list<keyValue<hashCode<Type>, SqlDbType>>();
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(bool), SqlDbType.Bit));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(byte), SqlDbType.TinyInt));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(sbyte), SqlDbType.TinyInt));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(short), SqlDbType.SmallInt));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(ushort), SqlDbType.SmallInt));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(int), SqlDbType.Int));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(uint), SqlDbType.Int));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(long), SqlDbType.BigInt));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(ulong), SqlDbType.BigInt));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(decimal), SqlDbType.Decimal));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(float), SqlDbType.Real));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(double), SqlDbType.Float));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(string), SqlDbType.NVarChar));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(DateTime), SqlDbType.DateTime));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(Guid), SqlDbType.UniqueIdentifier));
            formCSharpType.Add(new keyValue<hashCode<Type>, SqlDbType>(typeof(byte[]), SqlDbType.VarBinary));
            formCSharpTypes = new staticDictionary<hashCode<Type>, SqlDbType>(formCSharpType);
            #endregion

            MaxEnumValue = fastCSharp.Enum.GetMaxValue<SqlDbType>(-1) + 1;
            int dataIndex = 0, mapSize = ((MaxEnumValue + 31) >> 5) << 2;
            pointer[] datas = unmanaged.Get(true, mapSize, mapSize, MaxEnumValue * sizeof(int));
            stringTypeMap = new fixedMap(datas[dataIndex++]).Unsafer;
            textImageTypeMap = new fixedMap(datas[dataIndex++]).Unsafer;
            sizes = datas[dataIndex++];

            #region 字符串类型占位集合
            stringTypeMap.Set((int)SqlDbType.Char);
            stringTypeMap.Set((int)SqlDbType.NChar);
            stringTypeMap.Set((int)SqlDbType.VarChar);
            stringTypeMap.Set((int)SqlDbType.NVarChar);
            stringTypeMap.Set((int)SqlDbType.Text);
            stringTypeMap.Set((int)SqlDbType.NText);
            #endregion

            #region 文本类型占位集合
            textImageTypeMap.Set((int)SqlDbType.Text);
            textImageTypeMap.Set((int)SqlDbType.NText);
            textImageTypeMap.Set((int)SqlDbType.Image);
            #endregion

            #region 类型默认长度
            int* sizeData = sizes.Int;
            for (int i = 0; i != MaxEnumValue; i++) sizeData[i] = UnknownSize;
            sizeData[(int)SqlDbType.BigInt] = sizeof(long);
            sizeData[(int)SqlDbType.Binary] = 8000;
            sizeData[(int)SqlDbType.Bit] = sizeof(bool);
            sizeData[(int)SqlDbType.Char] = 8000;
            //TypeSize[(int)SqlDbType.Date] = sizeof(long);
            sizeData[(int)SqlDbType.DateTime] = sizeof(long);
            //TypeSize[(int)SqlDbType.DateTime2] = sizeof(long);
            //TypeSize[(int)SqlDbType.DateTimeOffset] = sizeof(long);
            sizeData[(int)SqlDbType.Decimal] = sizeof(decimal);
            sizeData[(int)SqlDbType.Float] = sizeof(double);
            sizeData[(int)SqlDbType.Image] = int.MaxValue;
            sizeData[(int)SqlDbType.Int] = sizeof(int);
            sizeData[(int)SqlDbType.Money] = sizeof(decimal);
            //TypeSize[(int)SqlDbType.NChar] = MaxStringSize;
            sizeData[(int)SqlDbType.NText] = int.MaxValue;
            //TypeSize[(int)SqlDbType.NVarChar] = MaxStringSize;
            sizeData[(int)SqlDbType.Real] = sizeof(float);
            sizeData[(int)SqlDbType.UniqueIdentifier] = 8;
            sizeData[(int)SqlDbType.SmallDateTime] = sizeof(long);
            sizeData[(int)SqlDbType.SmallInt] = sizeof(short);
            sizeData[(int)SqlDbType.SmallMoney] = sizeof(decimal);
            sizeData[(int)SqlDbType.Text] = int.MaxValue;
            //TypeSize[(int)SqlDbType.Time] = 8;
            sizeData[(int)SqlDbType.Timestamp] = 8;
            sizeData[(int)SqlDbType.TinyInt] = sizeof(byte);
            sizeData[(int)SqlDbType.VarBinary] = 8000;
            sizeData[(int)SqlDbType.VarChar] = 8000;
            //TypeSize[(int)SqlDbType.Xml] = -1;
            #endregion
        }