private static unsafe void toJson(fastCSharp.emit.jsonSerializer toJsoner, cardMessage value) { if (value.card_ext.signature == null) { log.Default.Add("卡券扩展 签名为空", new System.Diagnostics.StackFrame(), true); fastCSharp.web.ajax.WriteObject(toJsoner.UnsafeCharStream); } else { toJsoner.UnsafeWriteFirstName("card_id"); toJsoner.UnsafeToJson(value.card_id); toJsoner.UnsafeWriteNextName("card_ext"); fastCSharp.emit.jsonSerializer cardToJsoner = typePool <fastCSharp.emit.jsonSerializer> .Pop() ?? new fastCSharp.emit.jsonSerializer(); pointer buffer = fastCSharp.unmanagedPool.StreamBuffers.Get(); try { using (charStream cardJsonStream = cardToJsoner.UnsafeCharStream) { cardJsonStream.UnsafeReset((byte *)buffer.Char, fastCSharp.unmanagedPool.StreamBuffers.Size); cardToJsoner.UnsafeToJsonNotNull(value.card_ext, toJsoner.UnsafeConfig); fastCSharp.web.ajax.UnsafeFormatJavascript(cardJsonStream, toJsoner.UnsafeCharStream); } } finally { fastCSharp.unmanagedPool.StreamBuffers.Push(ref buffer); toJsoner.UnsafeFree(); } toJsoner.UnsafeCharStream.Write('}'); } }
internal unsafe charStream ResetJsonStream(void *data, int size) { if (jsonStream == null) { return(jsonStream = new charStream((char *)data, size >> 1)); } jsonStream.UnsafeReset((byte *)data, size); return(jsonStream); }
/// <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); }
/// <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)); }
/// <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)); }
/// <summary> /// 获取类型信息 /// </summary> /// <param name="type"></param> /// <returns></returns> private xmlNode get(Type type) { if (type != null) { xmlNode node; if (typeLock.TryGetValue(type, out node)) { return(node); } try { hashString typeName; pointer buffer = unmanagedPool.StreamBuffers.Get(); try { using (typeNameStream) { typeNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size); type.nameBuilder nameBuilder = new type.nameBuilder { NameStream = typeNameStream, IsXml = true }; nameBuilder.Xml(type); typeName = typeNameStream.ToString(); } } finally { unmanagedPool.StreamBuffers.Push(ref buffer); } if (types.TryGetValue(typeName, out node)) { types.Remove(typeName); } typeLock.Set(type, node); } finally { typeLock.Exit(); } return(node); } return(default(xmlNode)); }
/// <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)); }