public Buffer(System.ArraySegment <byte> segment, bool setLength) { _buffer = segment.Array; _offset = segment.Offset; _capacity = segment.Count; _length = setLength ? _capacity : 0; }
static StackObject *ProcessCache_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 4); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.ArraySegment <System.Byte> @buffer = (System.ArraySegment <System.Byte>) typeof(System.ArraySegment <System.Byte>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String @version = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.String @name = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 4); EB.Sparx.DataCacheManager instance_of_this_method = (EB.Sparx.DataCacheManager) typeof(EB.Sparx.DataCacheManager).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.ProcessCache(@name, @version, @buffer); return(__ret); }
private static async System.Threading.Tasks.Task <string> ReceiveStringAsync( WebSocket socket, System.Threading.CancellationToken ct) { System.ArraySegment <byte> buffer = new System.ArraySegment <byte>(new byte[8192]); using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { System.Net.WebSockets.WebSocketReceiveResult result; do { ct.ThrowIfCancellationRequested(); result = await socket.ReceiveAsync(buffer, ct); ms.Write(buffer.Array, buffer.Offset, result.Count); } while (!result.EndOfMessage); ms.Seek(0, System.IO.SeekOrigin.Begin); if (result.MessageType != System.Net.WebSockets.WebSocketMessageType.Text) { return(null); } // Encoding UTF8: https://tools.ietf.org/html/rfc6455#section-5.6 using (System.IO.TextReader reader = new System.IO.StreamReader(ms, System.Text.Encoding.UTF8)) { return(await reader.ReadToEndAsync()); } } }
// address = object address (start of header) System.ArraySegment <byte> ReadObjectBytes(System.UInt64 address, PackedManagedType typeDescription) { var size = ReadObjectSize(address, typeDescription); if (size <= 0) { return(new System.ArraySegment <byte>()); } var offset = TryBeginRead(address); if (offset < 0) { return(new System.ArraySegment <byte>()); } // Unity bug? For a reason that I do not understand, sometimes a memory segment is smaller // than the actual size of an object. In order to workaround this issue, we make sure to never // try to read more data from the segment than is available. if ((m_Bytes.Length - offset) < size) { //var wantedLength = size; size = m_Bytes.Length - offset; //Debug.LogErrorFormat("Cannot read entire string 0x{0:X}. The requested length in bytes is {1}, but the memory segment holds {2} bytes only.\n{3}...", address, wantedLength, size, System.Text.Encoding.Unicode.GetString(m_bytes, offset, Mathf.Min(size, 32))); if (size <= 0) { return(new System.ArraySegment <byte>()); } } var segment = new System.ArraySegment <byte>(m_Bytes, offset, size); return(segment); }
void FillSubMeshes() { subMeshes[subMeshCount - 1].FixIndexCount(indexCount); // 使用量が半分以下の場合、テンポラリにコピーしてから渡す if (vertexCount < (capacity / 2)) // 閾値は研究が必要だが、とりあえず。 { UnityEngine.Profiling.Profiler.BeginSample("DynamicMesh.Update.FillTemporary"); temporaryVertices.Clear(); temporaryUv.Clear(); temporaryColors.Clear(); var tmpV = new System.ArraySegment <Vector3>(vertices, 0, vertexCount); var tmpUv = new System.ArraySegment <Vector2>(uv, 0, vertexCount); var tmpC = new System.ArraySegment <Color32>(colors, 0, vertexCount); temporaryVertices.AddRange(tmpV); temporaryUv.AddRange(tmpUv); temporaryColors.AddRange(tmpC); mesh.SetVertices(temporaryVertices); mesh.SetUVs(0, temporaryUv); mesh.SetColors(temporaryColors); UnityEngine.Profiling.Profiler.EndSample(); } else // 半分以上使っている場合、そのまま渡す。 { UnityEngine.Profiling.Profiler.BeginSample("DynamicMesh.Update.CopyAll"); mesh.vertices = vertices; mesh.uv = uv; mesh.colors32 = colors; UnityEngine.Profiling.Profiler.EndSample(); } mesh.subMeshCount = subMeshCount; if ((materials == null) || (materials.Length != subMeshCount)) { materials = new Material[subMeshCount]; } for (int i = 0; i < subMeshCount; i++) { materials[i] = subMeshes[i].material; } meshRenderer.sharedMaterials = materials; var matrix = Matrix4x4.identity; for (int i = 0; i < subMeshCount; i++) { UnityEngine.Profiling.Profiler.BeginSample("DynamicMesh.Update.FillIndices"); var subMesh = subMeshes[i]; temporaryIndices.Clear(); var tmpI = new System.ArraySegment <int>(indices, subMesh.indexStart, subMesh.indexCount); temporaryIndices.AddRange(tmpI); mesh.SetTriangles(temporaryIndices, i, calculateBounds: false); UnityEngine.Profiling.Profiler.EndSample(); } }
} // End Sub Invoke private static System.Threading.Tasks.Task SendStringAsync( WebSocket socket, string data, System.Threading.CancellationToken ct) { byte[] buffer = System.Text.Encoding.UTF8.GetBytes(data); System.ArraySegment <byte> segment = new System.ArraySegment <byte>(buffer); return(socket.SendAsync(segment, System.Net.WebSockets.WebSocketMessageType.Text, true, ct)); }
public virtual string[][] GetSegments() { IList<string[]> segments = new List<string[]>(); int segmentLimit = factory.GetTarget().GetSerializedATNSegmentLimit(); for (int i = 0; i < serialized.Count; i += segmentLimit) { IList<string> currentSegment = new System.ArraySegment<string>(serialized.ToArray(), i, Math.Min(i + segmentLimit, serialized.Count) - i); segments.Add(currentSegment.ToArray()); } return segments.ToArray(); }
public System.ArraySegment <byte> ReadBytes(int count) { if (count + Length > _capacity) { throw new System.ArgumentOutOfRangeException("ReadBytes buffer underun length: " + Length + " count:" + count + " capacity" + _capacity); } var result = new System.ArraySegment <byte>(_buffer, _offset + _length, count); _length += count; return(result); }
public override void WritePayload(NetworkBinaryWriter writer) { var ms = new MemoryStream(); var nw = new NetworkBinaryWriter(ms); nw.Write(_header.ProtocolClassId); _header.WriteTo(nw, (ulong)_bodyLength); System.ArraySegment <byte> bufferSegment = ms.GetBufferSegment(); writer.Write((uint)bufferSegment.Count); writer.Write(bufferSegment.Array, bufferSegment.Offset, bufferSegment.Count); }
public void SendBinary(System.ArraySegment <byte> segment) { #if WS_DEBUG EB.Debug.Log("SendBinary: " + segment.Count); #endif //Debug.Log("Send: " + message); var frame = new WebSocketFrame(); frame.fin = true; frame.opcode = (int)WebSocketOpCode.Binary; frame.payload = new byte[segment.Count]; System.Array.Copy(segment.Array, segment.Offset, frame.payload, 0, segment.Count); QueueFrame(frame); }
public virtual string[][] GetSegments() { IList <string[]> segments = new List <string[]>(); int segmentLimit = factory.GetTarget().GetSerializedATNSegmentLimit(); for (int i = 0; i < serialized.Count; i += segmentLimit) { IList <string> currentSegment = new System.ArraySegment <string>(serialized.ToArray(), i, Math.Min(i + segmentLimit, serialized.Count) - i); segments.Add(currentSegment.ToArray()); } return(segments.ToArray()); }
internal static void Trace(string heading, Communicator communicator, System.ArraySegment <byte> buffer) { if (communicator.TraceLevels.Protocol >= 1) { var iss = new InputStream(communicator, Ice1Definitions.Encoding, buffer); using var s = new System.IO.StringWriter(CultureInfo.CurrentCulture); s.Write(heading); PrintMessage(s, iss); communicator.Logger.Trace(communicator.TraceLevels.ProtocolCat, s.ToString()); } }
internal static void TraceRecv(Communicator communicator, System.ArraySegment <byte> buffer) { if (communicator.TraceLevels.Protocol >= 1) { var iss = new InputStream(communicator, Ice1Definitions.Encoding, buffer); using var s = new System.IO.StringWriter(CultureInfo.CurrentCulture); Ice1Definitions.FrameType type = PrintMessage(s, iss); communicator.Logger.Trace(communicator.TraceLevels.ProtocolCat, "received " + GetFrameTypeAsString(type) + " " + s.ToString()); } }
static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref System.ArraySegment <System.Byte> instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.ArraySegment <System.Byte>[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
public override void WritePayload(NetworkBinaryWriter writer) { var ms = new MemoryStream(); var nw = new NetworkBinaryWriter(ms); nw.Write(_method.ProtocolClassId); nw.Write(_method.ProtocolMethodId); var argWriter = new MethodArgumentWriter(nw); _method.WriteArgumentsTo(argWriter); argWriter.Flush(); System.ArraySegment <byte> bufferSegment = ms.GetBufferSegment(); writer.Write((uint)bufferSegment.Count); writer.Write(bufferSegment.Array, bufferSegment.Offset, bufferSegment.Count); }
static StackObject *get_Array_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); System.ArraySegment <System.Byte> instance_of_this_method = (System.ArraySegment <System.Byte>) typeof(System.ArraySegment <System.Byte>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); var result_of_this_method = instance_of_this_method.Array; ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public WebsocketSessionPeer(WebSocket socket, System.Guid?id = null, string displayName = "", string iconUrl = "") { if (id == null || id == System.Guid.Empty) { IdAsGUID = System.Guid.NewGuid(); } else { IdAsGUID = (System.Guid)id; } this.Token = new Models.WebsocketSessionPeerToken(); this.Token.PeerId = IdAsGUID.ToString(); this.Token.DisplayName = displayName; this.Token.IconUrl = iconUrl; this.Socket = socket; System.ArraySegment <byte> segment = new System.ArraySegment <byte>(array: System.Text.Encoding.ASCII.GetBytes(this.Token.PeerId), offset: 0, count: this.Token.PeerId.Length); IdAsByteArray = segment.ToArray(); }
static int _m_ReadCStringBytes(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); MongoDB.Bson.IO.BsonStream gen_to_be_invoked = (MongoDB.Bson.IO.BsonStream)translator.FastGetCSObj(L, 1); { System.ArraySegment <byte> gen_ret = gen_to_be_invoked.ReadCStringBytes( ); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
void OnDataReceived(System.ArraySegment <byte> msg) { _packetsReceived++; _bytesReceived += (uint)msg.Array.Length; if (msg.Array.Length < PacketHeader.MinPacketLength) { return; } using (var str = new MemoryStream(msg.Array)) { var header = new PacketHeader(msg.Array); var data = new byte[header.ContentLength]; str.Seek(PacketHeader.MinPacketLength, SeekOrigin.Begin); str.Read(data, 0, header.ContentLength); if (header.Compressed) { ProcessReceivedMessage((ServerPacketID)header.PacketID, CLZF2.Decompress(data)); } else { ProcessReceivedMessage((ServerPacketID)header.PacketID, data); } } }
static int _m_AccessBackingBytes(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); MongoDB.Bson.IO.IByteBuffer gen_to_be_invoked = (MongoDB.Bson.IO.IByteBuffer)translator.FastGetCSObj(L, 1); { int _position = LuaAPI.xlua_tointeger(L, 2); System.ArraySegment <byte> gen_ret = gen_to_be_invoked.AccessBackingBytes(_position); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public static System.Threading.Tasks.Task <int> SendToAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP) { throw null; }
public static System.Threading.Tasks.Task <int> ReceiveAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags) { throw null; }
public static System.Threading.Tasks.Task <System.Net.Sockets.SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEndPoint) { throw null; }
protected BasicTypes(string fullName, string name) { _str = ""; _wstr = ""; _blob = new System.ArraySegment<byte>(); }
// 描画キックを行う public void UpdateMesh() { // ■だけは常に入れておく。他は文字描画要求の都度投げる font.RequestCharactersInTexture(whiteString); // 描画キック mesh.Clear(); if (subMeshCount > 0) { subMeshes[subMeshCount - 1].FixIndexCount(indexCount); // 使用量が半分以下の場合、テンポラリにコピーしてから渡す if (vertexCount < (capacity / 2)) // 閾値は研究が必要だが、とりあえず。 { UnityEngine.Profiling.Profiler.BeginSample("DebugPrimitiveRenderer.UpdateMesh.FillTemporary"); temporaryVertices.Clear(); temporaryUv.Clear(); temporaryColors.Clear(); var tmpV = new System.ArraySegment <Vector3>(vertices, 0, vertexCount); var tmpUv = new System.ArraySegment <Vector2>(uv, 0, vertexCount); var tmpC = new System.ArraySegment <Color32>(colors, 0, vertexCount); temporaryVertices.AddRange(tmpV); temporaryUv.AddRange(tmpUv); temporaryColors.AddRange(tmpC); mesh.SetVertices(temporaryVertices); mesh.SetUVs(0, temporaryUv); mesh.SetColors(temporaryColors); UnityEngine.Profiling.Profiler.EndSample(); } else // 半分以上使っている場合、そのまま渡す。 { UnityEngine.Profiling.Profiler.BeginSample("DebugPrimitiveRenderer.UpdateMesh.CopyAll"); mesh.vertices = vertices; mesh.uv = uv; mesh.colors32 = colors; UnityEngine.Profiling.Profiler.EndSample(); } mesh.subMeshCount = subMeshCount; Material[] materials = new Material[subMeshCount]; for (int i = 0; i < subMeshCount; i++) { materials[i] = subMeshes[i].material; } meshRenderer.sharedMaterials = materials; for (int i = 0; i < subMeshCount; i++) { UnityEngine.Profiling.Profiler.BeginSample("DebugPrimitiveRenderer.UpdateMesh.FillIndices"); var subMesh = subMeshes[i]; temporaryIndices.Clear(); var tmpI = new System.ArraySegment <int>(indices, subMesh.indexStart, subMesh.indexCount); temporaryIndices.AddRange(tmpI); mesh.SetTriangles(temporaryIndices, i, true); materialPropertyBlock.SetTexture( textureShaderPropertyId, subMesh.texture); meshRenderer.SetPropertyBlock(materialPropertyBlock, i); UnityEngine.Profiling.Profiler.EndSample(); } } meshFilter.sharedMesh = mesh; vertexCount = 0; indexCount = 0; texture = null; // 毎フレーム白にリセット Color = new Color32(255, 255, 255, 255); subMeshCount = 0; // どうもおかしいので毎フレーム取ってみる。 CharacterInfo ch; font.GetCharacterInfo(whiteChar, out ch); whiteUv = ch.uvTopLeft; whiteUv += ch.uvTopRight; whiteUv += ch.uvBottomLeft; whiteUv += ch.uvBottomRight; whiteUv *= 0.25f; }
public static System.Threading.Tasks.Task <System.Net.Sockets.SocketReceiveFromResult> ReceiveFromAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEndPoint) { return(default(System.Threading.Tasks.Task <System.Net.Sockets.SocketReceiveFromResult>)); }
public static System.Threading.Tasks.Task <int> SendToAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP) { return(default(System.Threading.Tasks.Task <int>)); }
public static System.Threading.Tasks.Task <int> ReceiveAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags) { return(default(System.Threading.Tasks.Task <int>)); }
public System.Threading.Tasks.Task <System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync(string?subProtocol, int receiveBufferSize, System.TimeSpan keepAliveInterval, System.ArraySegment <byte> internalBuffer) { throw null; }
public static System.Span <T> AsSpan <T>(this System.ArraySegment <T> segment, int start, int length) { throw null; }
public static System.Span <T> AsSpan <T>(this System.ArraySegment <T> segment) { throw null; }
public static System.Memory <T> AsMemory <T>(this System.ArraySegment <T> segment, int start) { throw null; }