Exemple #1
0
        /// <summary>
        /// 获取Excel客户端
        /// </summary>
        /// <returns>Excel客户端</returns>
        public unsafe client GetClient()
        {
            provider provider = Enum <providerType, provider> .Array((byte)Provider);

            pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();

            try
            {
                using (charStream connectionStream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize))
                {
                    connectionStream.SimpleWriteNotNull("Provider=");
                    connectionStream.Write(provider.Name);
                    connectionStream.SimpleWriteNotNull(";Data Source=");
                    connectionStream.Write(DataSource);
                    if (Password != null)
                    {
                        connectionStream.WriteNotNull(";Database Password="******";Extended Properties='");
                    connectionStream.Write(provider.Excel);
                    connectionStream.WriteNotNull(IsTitleColumn ? ";HDR=YES;IMEX=" : ";HDR=NO;IMEX=");
                    number.ToString((byte)Intermixed, connectionStream);
                    connectionStream.Write('\'');
                    return((client) new sql.connection {
                        Type = type.Excel, Connection = connectionStream.ToString()
                    }.Client);
                }
            }
            finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
        }
        /// <summary>
        /// 转换表达式
        /// </summary>
        /// <param name="converter">表达式转换器</param>
        /// <param name="expression">表达式</param>
        private void convertInSet(sql.expression.converter converter, Expression expression)
        {
            charStream       stream           = converter.Stream;
            BinaryExpression binaryExpression = (BinaryExpression)expression;
            Expression       left             = binaryExpression.Left;

            converters[(int)left.NodeType](converter, left);
            stream.SimpleWriteNotNull(" In(");
            Action <charStream, object> toString = null;
            int index = -1;

            foreach (object value in (IEnumerable)((ConstantExpression)binaryExpression.Right).Value)
            {
                if (++index == 0)
                {
                    toString = constantConverter[value.GetType()];
                }
                else
                {
                    stream.Write(',');
                }
                if (toString == null)
                {
                    stringConverter(stream, value.ToString());
                }
                else
                {
                    toString(stream, value);
                }
            }
            stream.Write(')');
        }
Exemple #3
0
        /// <summary>
        /// 创建表格
        /// </summary>
        /// <param name="connection">SQL连接</param>
        /// <param name="table">表格信息</param>
        internal unsafe override bool createTable(DbConnection connection, table table)
        {
            string name = table.Columns.Name;

            if (connection != null && name != null && name.Length != 0 && table.Columns != null && table.Columns.Columns.Length != 0)
            {
                pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();
                try
                {
                    using (charStream sqlStream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize))
                    {
                        sqlStream.SimpleWriteNotNull("create table ");
                        sqlStream.SimpleWriteNotNull(name);
                        sqlStream.SimpleWriteNotNull(" (");
                        bool isNext = false;
                        foreach (column column in table.Columns.Columns)
                        {
                            if (isNext)
                            {
                                sqlStream.Write(',');
                            }
                            sqlStream.SimpleWriteNotNull(column.SqlName);
                            sqlStream.Write(' ');
                            sqlStream.Write(column.DbType.getSqlTypeName());
                            isNext = true;
                        }
                        sqlStream.Write(')');
                        return(executeNonQuery(connection, sqlStream.ToString()) >= 0);
                    }
                }
                finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
            }
            return(false);
        }
        /// <summary>
        /// 转换表达式
        /// </summary>
        /// <param name="converter">表达式转换器</param>
        /// <param name="expression">表达式</param>
        private void convertInSet(sql.expression.converter converter, Expression expression)
        {
            charStream       stream           = converter.Stream;
            BinaryExpression binaryExpression = (BinaryExpression)expression;
            Expression       left             = binaryExpression.Left;

            converters[(int)left.NodeType](converter, left);
            stream.Write(" In(");
            func <object, string> toString = null;
            int index = -1;

            foreach (object value in (IEnumerable)((ConstantExpression)binaryExpression.Right).Value)
            {
                if (++index == 0)
                {
                    toString = constantConverter.Default[value.GetType()];
                }
                else
                {
                    stream.Write(',');
                }
                stream.Write(toString != null ? toString(value) : constantConverter.convertConstantStringMssql(value.ToString()));
            }
            stream.Write(')');
        }
 /// <summary>
 /// AJAX响应输出处理
 /// </summary>
 /// <param name="js">JS输出流</param>
 protected unsafe override void ajax(charStream js)
 {
     js.WriteNotNull(@"{At:");
     {
         string _value1_ = At;
         if (_value1_ == null)
         {
             fastCSharp.web.ajax.WriteNull(js);
         }
         else
         {
             fastCSharp.web.ajax.ToString(_value1_, js);
         }
     }
     js.WriteNotNull(@",Environment:");
     {
         fastCSharp.document.environment _value1_ = Environment;
         if (_value1_ == null)
         {
             fastCSharp.web.ajax.WriteNull(js);
         }
         else
         {
             js.WriteNotNull(@"{FastCSharpPath:");
             {
                 string _value2_ = _value1_.FastCSharpPath;
                 if (_value2_ == null)
                 {
                     fastCSharp.web.ajax.WriteNull(js);
                 }
                 else
                 {
                     fastCSharp.web.ajax.ToString(_value2_, js);
                 }
             }
             js.WriteNotNull(@",VS2010:");
             {
                 bool _value2_ = _value1_.VS2010;
                 fastCSharp.web.ajax.ToString((bool)_value2_, js);
             }
             js.Write('}');
         }
     }
     js.WriteNotNull(@",WorkPath:");
     {
         string _value1_ = WorkPath;
         if (_value1_ == null)
         {
             fastCSharp.web.ajax.WriteNull(js);
         }
         else
         {
             fastCSharp.web.ajax.ToString(_value1_, js);
         }
     }
     js.Write('}');
 }
Exemple #6
0
 /// <summary>
 /// 字节流转换成JSON字符串
 /// </summary>
 /// <param name="jsonStream">JSON输出流,不能为null</param>
 /// <param name="start">起始位置,不能为null</param>
 /// <param name="end">结束位置,长度必须大于0</param>
 public unsafe static void ToJson(charStream jsonStream, byte *start, byte *end)
 {
     jsonStream.Write('[');
     for (web.ajax.ToString(*start, jsonStream); ++start != end; web.ajax.ToString(*start, jsonStream))
     {
         jsonStream.Write(',');
     }
     jsonStream.Write(']');
 }
Exemple #7
0
        /// <summary>
        /// 转换表达式
        /// </summary>
        /// <param name="converter">表达式转换器</param>
        /// <param name="expression">表达式</param>
        /// <param name="type">操作字符串</param>
        private void convertBinaryExpression(converter converter, BinaryExpression binaryExpression, string type)
        {
            charStream stream = converter.Stream;
            Expression left = binaryExpression.Left, right = binaryExpression.Right;

            stream.Write('(');
            if (left.IsSimple)
            {
                converters[(int)left.NodeType](converter, left);
                stream.Write('=');
                stream.Write('1');
            }
            else
            {
                converters[(int)left.NodeType](converter, left);
            }
            stream.Write(')');
            stream.Write(type);
            stream.Write('(');
            if (right.IsSimple)
            {
                converters[(int)right.NodeType](converter, right);
                stream.Write('=');
                stream.Write('1');
            }
            else
            {
                converters[(int)right.NodeType](converter, right);
            }
            stream.Write(')');
        }
Exemple #8
0
        /// <summary>
        /// 查询对象集合
        /// </summary>
        /// <typeparam name="valueType">对象类型</typeparam>
        /// <typeparam name="modelType">成员位图类型</typeparam>
        /// <param name="sqlTool">SQL操作工具</param>
        /// <param name="query">查询信息</param>
        /// <param name="keyName">关键之名称</param>
        /// <param name="memberMap">成员位图</param>
        /// <param name="sqlStream"></param>
        /// <returns></returns>
        private unsafe string selectKeys <valueType, modelType>
            (fastCSharp.emit.sqlTable.sqlTool <valueType, modelType> sqlTool, selectQuery <modelType> query, string keyName, fastCSharp.code.memberMap <modelType> memberMap, charStream sqlStream)
            where valueType : class, modelType
            where modelType : class
        {
            pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();

            try
            {
                using (sqlStream)
                {
                    sqlStream.UnsafeReset(buffer.Byte, SqlBufferSize << 1);
                    sqlStream.SimpleWriteNotNull("select ");
                    sqlModel <modelType> .GetNames(sqlStream, memberMap);

                    sqlStream.SimpleWriteNotNull(" from[");
                    sqlStream.SimpleWriteNotNull(sqlTool.TableName);
                    sqlStream.WriteNotNull("]with(nolock)where ");
                    sqlStream.SimpleWriteNotNull(keyName);
                    sqlStream.SimpleWriteNotNull(" in(select ");
                    sqlStream.SimpleWriteNotNull(keyName);
                    sqlStream.SimpleWriteNotNull(" from(select ");
                    sqlStream.SimpleWriteNotNull(keyName);
                    sqlStream.WriteNotNull(",row_number()over(");
                    int startIndex = sqlStream.Length;
                    query.WriteOrder(sqlTool, sqlStream);
                    int count = sqlStream.Length - startIndex;
                    sqlStream.SimpleWriteNotNull(")as ");
                    sqlStream.SimpleWriteNotNull(orderOverName);
                    sqlStream.SimpleWriteNotNull(" from[");
                    sqlStream.SimpleWriteNotNull(sqlTool.TableName);
                    sqlStream.SimpleWriteNotNull("]with(nolock)");
                    if (query.WriteWhereOnly(sqlTool, sqlStream))
                    {
                        sqlStream.SimpleWriteNotNull(")as T where ");
                        sqlStream.SimpleWriteNotNull(orderOverName);
                        sqlStream.SimpleWriteNotNull(" between ");
                        number.ToString(query.SkipCount, sqlStream);
                        sqlStream.SimpleWriteNotNull(" and ");
                        number.ToString(query.SkipCount + query.GetCount - 1, sqlStream);
                        sqlStream.Write(')');
                        if (count != 0)
                        {
                            sqlStream.Write(sqlStream.Char + startIndex, count);
                        }
                        return(sqlStream.ToString());
                    }
                }
            }
            finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
            return(null);
        }
Exemple #9
0
 /// <summary>
 /// 排序字符串
 /// </summary>
 /// <param name="sqlTable">数据库表格操作工具</param>
 /// <param name="sqlStream">SQL表达式流</param>
 internal void WriteOrder(fastCSharp.emit.sqlTable.sqlToolBase sqlTable, charStream sqlStream)
 {
     if (Orders != null)
     {
         int isNext = 0;
         sqlStream.SimpleWriteNotNull(" order by ");
         foreach (keyValue <LambdaExpression, bool> order in Orders)
         {
             if (isNext == 0)
             {
                 isNext = 1;
             }
             else
             {
                 sqlStream.Write(',');
             }
             keyValue <string, string> name = sqlTable.Client.GetSql(order.Key, sqlStream);
             if (order.Value)
             {
                 sqlStream.SimpleWriteNotNull(" desc");
             }
             if (!isCreatedIndex && name.Key != null)
             {
                 isCreatedIndex = true;
                 sqlTable.CreateIndex(name.Key, name.Value);
             }
         }
     }
     else if (SqlFieldOrders != null)
     {
         int isNext = 0;
         sqlStream.SimpleWriteNotNull(" order by ");
         foreach (keyValue <sqlModel.fieldInfo, bool> order in SqlFieldOrders)
         {
             if (isNext == 0)
             {
                 isNext = 1;
             }
             else
             {
                 sqlStream.Write(',');
             }
             sqlStream.SimpleWriteNotNull(order.Key.SqlFieldName);
             if (order.Value)
             {
                 sqlStream.SimpleWriteNotNull(" desc");
             }
         }
     }
 }
Exemple #10
0
 /// <summary>
 /// 数字转换成字符串
 /// </summary>
 /// <param name="value">数字值</param>
 /// <param name="jsonStream">JSON输出流</param>
 public unsafe static void ToString(sbyte value, charStream jsonStream)
 {
     if (value == 0)
     {
         jsonStream.Write('0');
     }
     else
     {
         if (value < 0)
         {
             char *chars   = jsonStream.GetPrepLengthCurrent(5);
             uint  value32 = (uint)-(int)value;
             *(int *)chars = '-' + ('0' << 16);
             *(chars + 2)  = 'x';
             *(chars + 3)  = (char)((value32 >> 4) + '0');
             *(chars + 4)  = (char)number.ToHex(value32 & 15);
             jsonStream.UnsafeAddLength(5);
         }
         else
         {
             char *chars   = jsonStream.GetPrepLengthCurrent(4);
             uint  value32 = (uint)(int)value;
             *(int *)chars = '0' + ('x' << 16);
             *(chars + 2)  = (char)((value32 >> 4) + '0');
             *(chars + 3)  = (char)number.ToHex(value32 & 15);
             jsonStream.UnsafeAddLength(4);
         }
     }
 }
Exemple #11
0
     /// <summary>
     /// 数字转换成字符串
     /// </summary>
     /// <param name="charStream"></param>
     /// <param name="values"></param>
     /// <param name="startIndex"></param>
     /// <param name="endIndex"></param>
     /// <param name="joinChar"></param>
     /// <param name="isWriteNull"></param>
     public void Join(charStream charStream, valueType[] values, int startIndex, int endIndex, char joinChar, bool isWriteNull)
     {
         if (startIndex != endIndex)
         {
             object[] parameters = null;
             do
             {
                 object value = values[startIndex];
                 if ((bool)hasValueMethod.Invoke(value, null))
                 {
                     if (parameters == null)
                     {
                         parameters = new object[] { null, charStream }
                     }
                     ;
                     parameters[0] = valueMethod.Invoke(value, null);
                     method.Invoke(null, parameters);
                 }
                 else if (isWriteNull)
                 {
                     fastCSharp.web.ajax.WriteNull(charStream);
                 }
                 if (++startIndex == endIndex)
                 {
                     return;
                 }
                 charStream.Write(joinChar);
             }while (true);
         }
     }
 }
Exemple #12
0
 /// <summary>
 /// AJAX响应输出处理
 /// </summary>
 /// <param name="js">JS输出流</param>
 protected unsafe override void ajax(charStream js)
 {
     js.WriteNotNull(@"{Return:");
     {
         int _value1_ = Return;
         fastCSharp.web.ajax.ToString((int)_value1_, js);
     }
     js.Write('}');
 }
Exemple #13
0
 private void convertConstant(charStream sqlStream, bool?value)
 {
     if (value == null)
     {
         fastCSharp.web.ajax.WriteNull(sqlStream);
     }
     else
     {
         sqlStream.Write((bool)value ? '1' : '0');
     }
 }
Exemple #14
0
        /// <summary>
        /// 转换表达式
        /// </summary>
        /// <param name="converter">表达式转换器</param>
        /// <param name="expression">表达式</param>
        private void convertConditional(converter converter, Expression expression)
        {
            charStream            stream = converter.Stream;
            ConditionalExpression conditionalExpression = (ConditionalExpression)expression;
            Expression            test = conditionalExpression.Test, ifTrue = conditionalExpression.IfTrue, ifFalse = conditionalExpression.IfFalse;

            stream.Write("case when ");
            if (test.IsSimple)
            {
                converters[(int)test.NodeType](converter, test);
                stream.Write('=');
                stream.Write('1');
            }
            else
            {
                converters[(int)test.NodeType](converter, test);
            }
            stream.Write(" then ");
            if (ifTrue.IsSimple)
            {
                converters[(int)ifTrue.NodeType](converter, ifTrue);
            }
            else
            {
                stream.Write('(');
                converters[(int)ifTrue.NodeType](converter, ifTrue);
                stream.Write(')');
            }
            stream.Write(" else ");
            if (ifFalse.IsSimple)
            {
                converters[(int)ifFalse.NodeType](converter, ifFalse);
            }
            else
            {
                stream.Write('(');
                converters[(int)ifFalse.NodeType](converter, ifFalse);
                stream.Write(')');
            }
            stream.Write(" end");
        }
Exemple #15
0
 /// <summary>
 /// 转换表达式
 /// </summary>
 /// <param name="converter">表达式转换器</param>
 /// <param name="expression">表达式</param>
 /// <param name="name">成员名称</param>
 private void convertMemberAccess(converter converter, MemberExpression memberExpression, string name)
 {
     if (memberExpression.Expression.GetType() == typeof(ParameterExpression))
     {
         if (converter.parameterMemberNames.indexOf(name) == -1)
         {
             converter.parameterMemberNames = converter.parameterMemberNames.add(name);
         }
         charStream stream = converter.Stream;
         if (converter.NameType != converter.getNameType.None)
         {
             stream.Write(converter.Name ?? converter.GetName(((ParameterExpression)memberExpression.Expression).Name));
             stream.Write('.');
         }
         stream.Write(name);
     }
     else
     {
         fastCSharp.log.Default.Throw("未知成员表达式类型 " + memberExpression.Expression.GetType().Name, false, true);
     }
 }
 /// <summary>
 /// AJAX响应输出处理
 /// </summary>
 /// <param name="js">JS输出流</param>
 protected unsafe override void ajax(charStream js)
 {
     js.WriteNotNull(@"{Item:");
     {
         fastCSharp.document.include.codeMenu.item _value1_ = Item;
         if (_value1_ == null)
         {
             fastCSharp.web.ajax.WriteNull(js);
         }
         else
         {
             js.WriteNotNull(@"{File:");
             {
                 System.IO.FileInfo _value2_ = _value1_.File;
                 if (_value2_ == null)
                 {
                     fastCSharp.web.ajax.WriteNull(js);
                 }
                 else
                 {
                     js.WriteNotNull(@"{FullName:");
                     {
                         string _value3_ = _value2_.FullName;
                         if (_value3_ == null)
                         {
                             fastCSharp.web.ajax.WriteNull(js);
                         }
                         else
                         {
                             fastCSharp.web.ajax.ToString(_value3_, js);
                         }
                     }
                     js.Write('}');
                 }
             }
             js.Write('}');
         }
     }
     js.Write('}');
 }
Exemple #17
0
        /// <summary>
        /// 转换表达式
        /// </summary>
        /// <param name="converter">表达式转换器</param>
        /// <param name="binaryExpression">表达式</param>
        /// <param name="char1">操作字符1</param>
        /// <param name="char2">操作字符2</param>
        protected void convertBinaryExpression(converter converter, BinaryExpression binaryExpression,
                                               char char1, char char2 = ' ')
        {
            charStream stream = converter.Stream;
            Expression left = binaryExpression.Left, right = binaryExpression.Right;

            if (left.IsSimple)
            {
                converters[(int)left.NodeType](converter, left);
            }
            else
            {
                stream.Write('(');
                converters[(int)left.NodeType](converter, left);
                stream.Write(')');
            }
            stream.Write(char1);
            stream.Write(char2);
            if (right.IsSimple)
            {
                converters[(int)right.NodeType](converter, right);
            }
            else
            {
                stream.Write('(');
                converters[(int)right.NodeType](converter, right);
                stream.Write(')');
            }
        }
Exemple #18
0
        /// <summary>
        /// 转换表达式
        /// </summary>
        /// <param name="converter">表达式转换器</param>
        /// <param name="expression">表达式</param>
        private void convertCall(converter converter, Expression expression)
        {
            MethodCallExpression methodCallExpression = (MethodCallExpression)expression;
            charStream           stream = converter.Stream;

            stream.SimpleWriteNotNull(methodCallExpression.Method.Name);
            stream.Write('(');
            if (methodCallExpression.Arguments != null)
            {
                bool isNext = false;
                foreach (Expression argumentExpression in methodCallExpression.Arguments)
                {
                    if (isNext)
                    {
                        stream.Write(',');
                    }
                    converters[(int)argumentExpression.NodeType](converter, argumentExpression);
                    isNext = true;
                }
            }
            stream.Write(')');
        }
Exemple #19
0
        /// <summary>
        /// 转换表达式
        /// </summary>
        /// <param name="converter">表达式转换器</param>
        /// <param name="expression">表达式</param>
        private void convertNotEqual(converter converter, Expression expression)
        {
            BinaryExpression binaryExpression = (BinaryExpression)expression;

            if (binaryExpression.Left.IsConstantNull)
            {
                charStream stream = converter.Stream;
                if (binaryExpression.Right.IsSimple)
                {
                    converters[(int)binaryExpression.Right.NodeType](converter, binaryExpression.Right);
                }
                else
                {
                    stream.Write('(');
                    converters[(int)binaryExpression.Right.NodeType](converter, binaryExpression.Right);
                    stream.Write(')');
                }
                stream.SimpleWriteNotNull(" is not null");
            }
            else if (binaryExpression.Right.IsConstantNull)
            {
                charStream stream = converter.Stream;
                if (binaryExpression.Left.IsSimple)
                {
                    converters[(int)binaryExpression.Left.NodeType](converter, binaryExpression.Left);
                }
                else
                {
                    stream.Write('(');
                    converters[(int)binaryExpression.Left.NodeType](converter, binaryExpression.Left);
                    stream.Write(')');
                }
                stream.SimpleWriteNotNull(" is not null");
            }
            else
            {
                convertNotEqual(converter, (BinaryExpression)expression);
            }
        }
Exemple #20
0
 /// <summary>
 /// 字符串
 /// </summary>
 /// <param name="value">字符串</param>
 /// <param name="jsonStream">JSON输出流</param>
 public static void ToString(ref subString value, charStream jsonStream)
 {
     if (value.value == null)
     {
         WriteNull(jsonStream);
     }
     else
     {
         jsonStream.PrepLength(value.Length + 2);
         jsonStream.UnsafeWrite(Quote);
         jsonStream.Write(ref value);
         jsonStream.UnsafeWrite(Quote);
     }
 }
Exemple #21
0
 /// <summary>
 /// 数字转换成字符串
 /// </summary>
 /// <param name="value">数字值</param>
 /// <param name="jsonStream">JSON输出流</param>
 public unsafe static void ToString(byte value, charStream jsonStream)
 {
     if (value == 0)
     {
         jsonStream.Write('0');
     }
     else
     {
         byte *chars = (byte *)jsonStream.GetPrepLengthCurrent(4);
         *(int *)chars = '0' + ('x' << 16);
         *(char *)(chars + sizeof(char) * 2) = (char)number.ToHex((uint)value >> 4);
         *(char *)(chars + sizeof(char) * 3) = (char)number.ToHex((uint)value & 15);
         jsonStream.UnsafeAddLength(4);
     }
 }
Exemple #22
0
 /// <summary>
 /// 数字转换成字符串
 /// </summary>
 /// <param name="charStream"></param>
 /// <param name="values"></param>
 /// <param name="startIndex"></param>
 /// <param name="endIndex"></param>
 /// <param name="joinChar"></param>
 /// <param name="isWriteNull"></param>
 public void Join(charStream charStream, valueType[] values, int startIndex, int endIndex, char joinChar, bool isWriteNull)
 {
     if (startIndex != endIndex)
     {
         object[] parameters = new object[] { null, charStream };
         do
         {
             parameters[0] = values[startIndex];
             method.Invoke(null, parameters);
             if (++startIndex == endIndex)
             {
                 return;
             }
             charStream.Write(joinChar);
         }while (true);
     }
 }
Exemple #23
0
        /// <summary>
        /// 数字转换成字符串
        /// </summary>
        /// <param name="value">数字值</param>
        /// <param name="jsonStream">JSON输出流</param>
        public unsafe static void ToString(ushort value, charStream jsonStream)
        {
            char *chars;

            if (value < 10000)
            {
                if (value < 10)
                {
                    jsonStream.Write((char)(value + '0'));
                    return;
                }
                int div10 = (value * (int)fastCSharp.number.Div10_16Mul) >> fastCSharp.number.Div10_16Shift;
                if (div10 < 10)
                {
                    *(chars = jsonStream.GetPrepLengthCurrent(2)) = (char)(div10 + '0');
                    *(chars + 1) = (char)((value - div10 * 10) + '0');
                    jsonStream.UnsafeAddLength(2);
                    return;
                }
                int div100 = (div10 * (int)fastCSharp.number.Div10_16Mul) >> fastCSharp.number.Div10_16Shift;
                if (div100 < 10)
                {
                    *(chars = jsonStream.GetPrepLengthCurrent(3)) = (char)(div100 + '0');
                    *(chars + 1) = (char)((div10 - div100 * 10) + '0');
                    *(chars + 2) = (char)((value - div10 * 10) + '0');
                    jsonStream.UnsafeAddLength(3);
                    return;
                }
                int div1000 = (div100 * (int)fastCSharp.number.Div10_16Mul) >> fastCSharp.number.Div10_16Shift;
                *(chars = jsonStream.GetPrepLengthCurrent(4)) = (char)(div1000 + '0');
                *(chars + 1) = (char)((div100 - div1000 * 10) + '0');
                *(chars + 2) = (char)((div10 - div100 * 10) + '0');
                *(chars + 3) = (char)((value - div10 * 10) + '0');
                jsonStream.UnsafeAddLength(4);
                return;
            }
            *(int *)(chars = jsonStream.GetPrepLengthCurrent(6)) = '0' + ('x' << 16);
            toHex16(value, chars + 2);
            jsonStream.UnsafeAddLength(6);
        }
Exemple #24
0
        /// <summary>
        /// 添加消息
        /// </summary>
        /// <param name="message">消息</param>
        private void newMessage(server.message message)
        {
            using (charStream charStream = new charStream())
            {
                charStream.Write(@"
");
                charStream.Write(message.User);
                charStream.Write(" ");
                charStream.Write(message.Time.toString());
                charStream.Write(@" :
");
                charStream.Write(message.Message);
                messageTextBox.AppendText(charStream.ToString());
            }
            messageTextBox.ScrollToCaret();
        }
Exemple #25
0
 /// <summary>
 /// 获取字段信息
 /// </summary>
 /// <param name="field"></param>
 /// <returns></returns>
 private xmlNode get(FieldInfo field)
 {
     if (field != null)
     {
         xmlNode node;
         if (fieldLock.TryGetValue(field, out node))
         {
             return(node);
         }
         try
         {
             hashString fieldName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (fieldNameStream)
                 {
                     fieldNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = fieldNameStream, IsXml = true
                     };
                     nameBuilder.Xml(field.DeclaringType);
                     fieldNameStream.Write('.');
                     fieldNameStream.SimpleWriteNotNull(field.Name);
                     fieldName = fieldNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (fields.TryGetValue(fieldName, out node))
             {
                 fields.Remove(fieldName);
             }
             fieldLock.Set(field, node);
         }
         finally { fieldLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Exemple #26
0
 /// <summary>
 /// 获取属性信息
 /// </summary>
 /// <param name="property"></param>
 /// <returns></returns>
 private xmlNode get(PropertyInfo property)
 {
     if (property != null)
     {
         xmlNode node;
         if (propertyLock.TryGetValue(property, out node))
         {
             return(node);
         }
         try
         {
             hashString propertyName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (propertyNameStream)
                 {
                     propertyNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = propertyNameStream, IsXml = true
                     };
                     nameBuilder.Xml(property.DeclaringType);
                     propertyNameStream.Write('.');
                     propertyNameStream.SimpleWriteNotNull(property.Name);
                     propertyName = propertyNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (properties.TryGetValue(propertyName, out node))
             {
                 properties.Remove(propertyName);
             }
             propertyLock.Set(property, node);
         }
         finally { propertyLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Exemple #27
0
 /// <summary>
 /// 生成HTML
 /// </summary>
 /// <param name="isTag">是否包含当前标签</param>
 /// <returns>HTML</returns>
 public string Html(bool isTag)
 {
     if (TagName != null)
     {
         if (web.html.NonanalyticTagNames.Contains(TagName))
         {
             if (isTag && TagName.Length != 1)
             {
                 using (charStream strings = new charStream())
                 {
                     tagHtml(strings);
                     strings.Write(nodeText.Html);
                     tagRound(strings);
                     return strings.ToString();
                 }
             }
         }
         else
         {
             using (charStream strings = new charStream())
             {
                 if (isTag) tagHtml(strings);
                 if (children.count() != 0)
                 {
                     htmlNode node;
                     list<nodeIndex> values = new list<nodeIndex>();
                     nodeIndex index = new nodeIndex { Values = children };
                     while (true)
                     {
                         if (index.Values == null)
                         {
                             if (values.Count == 0) break;
                             {
                                 index = values.Pop();
                                 index.Values[index.Index].tagRound(strings);
                                 if (++index.Index == index.Values.Count)
                                 {
                                     index.Values = null;
                                     continue;
                                 }
                             }
                         }
                         node = index.Values[index.Index];
                         string nodeTagName = node.TagName;
                         bool isNonanalyticTagNames = nodeTagName != null && web.html.NonanalyticTagNames.Contains(nodeTagName);
                         if (node.children.count() == 0 || nodeTagName == null || isNonanalyticTagNames)
                         {
                             if (nodeTagName != null && nodeTagName.Length != 1) node.tagHtml(strings);
                             strings.Write(node.nodeText.Html);
                             if (nodeTagName != null && nodeTagName.Length != 1) node.tagRound(strings);
                             if (++index.Index == index.Values.Count) index.Values = null;
                         }
                         else
                         {
                             node.tagHtml(strings);
                             values.Add(index);
                             index.Values = node.children;
                             index.Index = 0;
                         }
                     }
                 }
                 if (isTag) tagRound(strings);
                 return strings.ToString();
             }
         }
     }
     return nodeText.Html;
 }
Exemple #28
0
 /// <summary>
 /// 获取方法信息
 /// </summary>
 /// <param name="method"></param>
 /// <returns></returns>
 private xmlNode get(MethodInfo method)
 {
     if (method != null)
     {
         xmlNode node;
         if (methodLock.TryGetValue(method, out node))
         {
             return(node);
         }
         try
         {
             hashString methodName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (methodNameStream)
                 {
                     methodNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = methodNameStream, IsXml = true
                     };
                     nameBuilder.Xml(method.DeclaringType);
                     methodNameStream.Write('.');
                     string name = method.Name;
                     if (name[0] == '.')
                     {
                         methodNameStream.Write('#');
                         methodNameStream.Write(subString.Unsafe(name, 1, name.Length - 1));
                     }
                     else
                     {
                         methodNameStream.SimpleWriteNotNull(name);
                     }
                     ParameterInfo[] parameters = method.GetParameters();
                     if (parameters.Length != 0)
                     {
                         bool isFirst = true;
                         methodNameStream.Write('(');
                         foreach (ParameterInfo parameter in parameters)
                         {
                             if (isFirst)
                             {
                                 isFirst = false;
                             }
                             else
                             {
                                 methodNameStream.Write(',');
                             }
                             nameBuilder.Xml(parameter.ParameterType);
                         }
                         methodNameStream.Write(')');
                     }
                     formatName(methodNameStream.Char, methodNameStream.CurrentChar);
                     methodName = methodNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (methods.TryGetValue(methodName, out node))
             {
                 methods.Remove(methodName);
             }
             methodLock.Set(method, node);
         }
         finally { methodLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Exemple #29
0
 /// <summary>
 /// 生成标签html
 /// </summary>
 /// <param name="strings">html流</param>
 private void tagHtml(charStream strings)
 {
     if (TagName.Length != 0)
     {
         strings.Write('<');
         strings.Write(TagName);
         if (attributes != null)
         {
             foreach (KeyValuePair<string, htmlText> attribute in attributes)
             {
                 strings.Write(' ');
                 strings.Write(HttpUtility.HtmlEncode(attribute.Key));
                 strings.Write(@"=""");
                 strings.Write(attribute.Value.Html);
                 strings.Write(@"""");
             }
         }
         if (web.html.CanNonRoundTagNames.Contains(TagName) && children == null && nodeText.Html == null) strings.Write(" /");
         strings.Write('>');
     }
 }
Exemple #30
0
 /// <summary>
 /// 获取XML注释文档名称
 /// </summary>
 /// <param name="type"></param>
 public void Xml(Type type)
 {
     if (type.IsArray)
     {
         array(type, true);
     }
     else if (type.IsGenericType)
     {
         genericFullName(type);
     }
     else
     {
         Type reflectedType = type.ReflectedType;
         if (reflectedType == null)
         {
             NameStream.SimpleWriteNotNull(type.Namespace);
             NameStream.Write('.');
             NameStream.SimpleWriteNotNull(type.Name);
         }
         else
         {
             this.reflectedType(type, reflectedType);
         }
     }
 }
Exemple #31
0
            /// <summary>
            /// 任意类型处理
            /// </summary>
            /// <param name="type">类型</param>
            private void getFullName(Type type)
            {
                string value = typeNames.Get(type, null);

                if (value != null)
                {
                    nameStream.Write(value);
                }
                else if (type.IsGenericParameter)
                {
                    nameStream.Write(type.Name);
                }
                else if (type.IsArray)
                {
                    array(type, true);
                }
                else if (type.IsGenericType)
                {
                    genericFullName(type);
                }
                else
                {
                    Type reflectedType = type.ReflectedType;
                    if (reflectedType == null)
                    {
                        nameStream.Write(type.Namespace);
                        nameStream.Write('.');
                        nameStream.Write(type.Name);
                    }
                    else
                    {
                        this.reflectedType(type, reflectedType);
                    }
                }
            }
Exemple #32
0
 private void convertConstant(charStream sqlStream, bool value)
 {
     sqlStream.Write(value ? '1' : '0');
 }
Exemple #33
0
 /// <summary>
 /// 生成标签结束
 /// </summary>
 /// <param name="strings">html流</param>
 private void tagRound(charStream strings)
 {
     if (TagName.Length != 0
         && (!web.html.CanNonRoundTagNames.Contains(TagName) || children != null || nodeText.Html != null))
     {
         strings.Write("</");
         strings.Write(TagName);
         strings.Write(">");
     }
 }