mirror of
https://github.com/RRQM/TouchSocket.git
synced 2025-12-19 01:46:44 +08:00
同步代码,格式化代码
This commit is contained in:
@@ -86,7 +86,7 @@ class MyBigFixedHeaderCustomDataHandlingAdapter : CustomBigFixedHeaderDataHandli
|
||||
|
||||
```csharp
|
||||
TcpService service = new TcpService();
|
||||
service.Received += (client, e) =>
|
||||
service.Received = (client, e) =>
|
||||
{
|
||||
//接收信息,在CustomDataHandlingAdapter派生的适配器中,byteBlock将为null,requestInfo将为适配器定义的泛型
|
||||
if (e.RequestInfo is MyBigFixedHeaderRequestInfo myRequestInfo)
|
||||
|
||||
@@ -85,7 +85,7 @@ class MyCustomBetweenAndDataHandlingAdapter : CustomBetweenAndDataHandlingAdapte
|
||||
|
||||
```csharp
|
||||
TcpService service = new TcpService();
|
||||
service.Received += (client, e) =>
|
||||
service.Received = (client, e) =>
|
||||
{
|
||||
//接收信息,在CustomDataHandlingAdapter派生的适配器中,byteBlock将为null,requestInfo将为适配器定义的泛型
|
||||
if (e.RequestInfo is MyBetweenAndRequestInfo myRequestInfo)
|
||||
|
||||
@@ -117,7 +117,7 @@ public class MyCustomUnfixedHeaderDataHandlingAdapter : CustomUnfixedHeaderDataH
|
||||
|
||||
```csharp
|
||||
TcpService service = new TcpService();
|
||||
service.Received += (client, e) =>
|
||||
service.Received = (client, e) =>
|
||||
{
|
||||
//接收信息,在CustomDataHandlingAdapter派生的适配器中,byteBlock将为null,requestInfo将为适配器定义的泛型
|
||||
if (e.RequestInfo is MyUnfixedHeaderRequestInfo myRequestInfo)
|
||||
|
||||
@@ -35,7 +35,7 @@ adapter.SendCallBack = (buffer, offset, length) =>
|
||||
}
|
||||
};
|
||||
|
||||
adapter.ReceivedCallBack += (byteBlock, requestInfo) =>
|
||||
adapter.ReceivedCallBack = (byteBlock, requestInfo) =>
|
||||
{
|
||||
//此处会回调接收的最终触发,例如:此处使用的固定包头,会解析4+n的数据为n。
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Pipeline适配器,是结合IOCP与管道模型结合的产物。功能类似
|
||||
```csharp
|
||||
TcpService service = new TcpService();
|
||||
|
||||
service.Received += (client, e) =>
|
||||
service.Received = (client, e) =>
|
||||
{
|
||||
if (e.RequestInfo is Pipeline pipeline)//实际上Pipeline继承自Stream
|
||||
{
|
||||
|
||||
@@ -178,7 +178,7 @@ tcpClient.Connect();//调用连接,当连接不成功时,会抛出异常。
|
||||
|
||||
```csharp
|
||||
var tcpClient = new TcpClient();
|
||||
tcpClient.Received += (client, e) =>
|
||||
tcpClient.Received = (client, e) =>
|
||||
{
|
||||
//从服务器收到信息
|
||||
string mes = Encoding.UTF8.GetString(e.ByteBlock.Buffer, 0, e.ByteBlock.Len);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<ApplicationIcon>logo.ico</ApplicationIcon>
|
||||
<SignAssembly>True</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>Sign.snk</AssemblyOriginatorKeyFile>
|
||||
<Version>2.0.0-beta.213</Version>
|
||||
<Version>2.0.0-beta.215</Version>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Company>若汝棋茗</Company>
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace TouchSocket.Dmtp.AspNetCore
|
||||
private int m_receiveBufferSize = 1024 * 10;
|
||||
private int m_sendBufferSize = 1024 * 10;
|
||||
private readonly SemaphoreSlim m_semaphoreForSend = new SemaphoreSlim(1, 1);
|
||||
|
||||
#endregion 字段
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -61,6 +62,7 @@ namespace TouchSocket.Dmtp.AspNetCore
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int SendBufferSize => this.m_sendBufferSize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public TouchSocketConfig Config { get; private set; }
|
||||
|
||||
@@ -253,10 +255,8 @@ namespace TouchSocket.Dmtp.AspNetCore
|
||||
{
|
||||
this.m_semaphoreForSend.Release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion 内部委托绑定
|
||||
|
||||
#region 事件
|
||||
@@ -337,7 +337,7 @@ namespace TouchSocket.Dmtp.AspNetCore
|
||||
throw new NotSupportedException("不支持该功能");
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Receiver
|
||||
|
||||
internal void SetDmtpActor(DmtpActor actor)
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace TouchSocket.Core.AspNetCore
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object Resolve(Type fromType,string key = "")
|
||||
public object Resolve(Type fromType, string key = "")
|
||||
{
|
||||
if (key.HasValue())
|
||||
{
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Resources;
|
||||
|
||||
@@ -64,7 +62,6 @@ namespace TouchSocket.Core
|
||||
/// <exception cref="MessageRegisteredException"></exception>
|
||||
public void Add(string token, MessageInstance messageInstance)
|
||||
{
|
||||
|
||||
if (this.m_tokenAndInstance.TryGetValue(token, out var value))
|
||||
{
|
||||
if (!this.AllowMultiple)
|
||||
@@ -116,7 +113,7 @@ namespace TouchSocket.Core
|
||||
/// <param name="token"></param>
|
||||
public void Remove(string token)
|
||||
{
|
||||
this.m_tokenAndInstance.TryRemove(token,out _);
|
||||
this.m_tokenAndInstance.TryRemove(token, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,7 +141,7 @@ namespace TouchSocket.Core
|
||||
|
||||
foreach (var item in key)
|
||||
{
|
||||
this.m_tokenAndInstance.TryRemove(item,out _);
|
||||
this.m_tokenAndInstance.TryRemove(item, out _);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
// 感谢您的下载和使用
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
//------------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TouchSocket.Core
|
||||
{
|
||||
@@ -63,18 +62,17 @@ namespace TouchSocket.Core
|
||||
}
|
||||
}
|
||||
|
||||
//#if NET6_0_OR_GREATER
|
||||
// public partial class DisposableObject : IAsyncDisposable
|
||||
// {
|
||||
// public ValueTask DisposeAsync()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
// public class DisposableObject1 : IAsyncDisposable
|
||||
// {
|
||||
|
||||
// }
|
||||
//#if NET6_0_OR_GREATER
|
||||
// public partial class DisposableObject : IAsyncDisposable
|
||||
// {
|
||||
// public ValueTask DisposeAsync()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
// public class DisposableObject1 : IAsyncDisposable
|
||||
// {
|
||||
// }
|
||||
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace TouchSocket.Core
|
||||
namespace TouchSocket.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态构建类型
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace TouchSocket.Core
|
||||
{
|
||||
try
|
||||
{
|
||||
source = JsonConvert.SerializeObject(target, JsonSettings).ToUTF8Bytes();
|
||||
source = JsonConvert.SerializeObject(target, this.JsonSettings).ToUTF8Bytes();
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace TouchSocket.Core
|
||||
{
|
||||
try
|
||||
{
|
||||
source = JsonConvert.SerializeObject(target, JsonSettings);
|
||||
source = JsonConvert.SerializeObject(target, this.JsonSettings);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -728,7 +728,7 @@ namespace TouchSocket.Core
|
||||
if ((crc & 1) > 0)
|
||||
crc = (crc >> 1) ^ 0xEDB88320;// 0xEDB88320= reverse 0x04C11DB7
|
||||
else
|
||||
crc = crc >> 1;
|
||||
crc >>= 1;
|
||||
}
|
||||
}
|
||||
var ret = BitConverter.GetBytes(~crc);
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace TouchSocket.Core
|
||||
{
|
||||
var r = inStream.Read(byteIn, 0, byteIn.Length);
|
||||
encStream.Write(byteIn, 0, r);
|
||||
readLen = readLen + r;
|
||||
readLen += r;
|
||||
}
|
||||
encStream.Close();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace TouchSocket.Core
|
||||
byteBlock.Read(out var header, this.HeaderLength);
|
||||
if (requestInfo.OnParsingHeader(header))
|
||||
{
|
||||
if (requestInfo.BodyLength>this.MaxPackageSize)
|
||||
if (requestInfo.BodyLength > this.MaxPackageSize)
|
||||
{
|
||||
this.OnError($"接收的BodyLength={requestInfo.BodyLength},大于设定的MaxPackageSize={this.MaxPackageSize}");
|
||||
return FilterResult.GoOn;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TouchSocket.Core
|
||||
{
|
||||
@@ -60,7 +59,6 @@ namespace TouchSocket.Core
|
||||
this.Owner = owner;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在解析时发生错误。
|
||||
/// </summary>
|
||||
@@ -79,7 +77,6 @@ namespace TouchSocket.Core
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置解析器到初始状态,一般在<see cref="OnError(string, bool, bool)"/>被触发时,由返回值指示是否调用。
|
||||
/// </summary>
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace TouchSocket.Core
|
||||
/// <summary>
|
||||
/// 指定依赖类型。
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Property | AttributeTargets.Method| AttributeTargets.Parameter)]
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter)]
|
||||
public class DependencyInjectAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
@@ -25,7 +25,6 @@ namespace TouchSocket.Core
|
||||
/// </summary>
|
||||
public DependencyInjectAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace TouchSocket.Core
|
||||
/// <param name="fromType"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public object Resolve(Type fromType,string key = "")
|
||||
public object Resolve(Type fromType, string key = "")
|
||||
{
|
||||
if (fromType == typeof(IContainer))
|
||||
{
|
||||
@@ -99,11 +99,11 @@ namespace TouchSocket.Core
|
||||
{
|
||||
if (descriptor.ToType.IsGenericType)
|
||||
{
|
||||
return (descriptor.ToInstance = this.Create(descriptor,descriptor.ToType.MakeGenericType(fromType.GetGenericArguments())));
|
||||
return (descriptor.ToInstance = this.Create(descriptor, descriptor.ToType.MakeGenericType(fromType.GetGenericArguments())));
|
||||
}
|
||||
else
|
||||
{
|
||||
return descriptor.ToInstance = this.Create(descriptor,descriptor.ToType);
|
||||
return descriptor.ToInstance = this.Create(descriptor, descriptor.ToType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,11 +111,11 @@ namespace TouchSocket.Core
|
||||
|
||||
if (descriptor.ToType.IsGenericType)
|
||||
{
|
||||
return this.Create(descriptor,descriptor.ToType.MakeGenericType(fromType.GetGenericArguments()));
|
||||
return this.Create(descriptor, descriptor.ToType.MakeGenericType(fromType.GetGenericArguments()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Create(descriptor,descriptor.ToType);
|
||||
return this.Create(descriptor, descriptor.ToType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,10 +134,10 @@ namespace TouchSocket.Core
|
||||
}
|
||||
lock (descriptor)
|
||||
{
|
||||
return descriptor.ToInstance ??= this.Create(descriptor,descriptor.ToType);
|
||||
return descriptor.ToInstance ??= this.Create(descriptor, descriptor.ToType);
|
||||
}
|
||||
}
|
||||
return this.Create(descriptor,descriptor.ToType);
|
||||
return this.Create(descriptor, descriptor.ToType);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -163,7 +163,7 @@ namespace TouchSocket.Core
|
||||
this.m_registrations.TryRemove(k, out _);
|
||||
}
|
||||
|
||||
private object Create(DependencyDescriptor descriptor,Type toType)
|
||||
private object Create(DependencyDescriptor descriptor, Type toType)
|
||||
{
|
||||
var ctor = toType.GetConstructors().FirstOrDefault(x => x.IsDefined(typeof(DependencyInjectAttribute), true));
|
||||
if (ctor is null)
|
||||
@@ -175,7 +175,7 @@ namespace TouchSocket.Core
|
||||
}
|
||||
ctor = toType.GetConstructors().OrderByDescending(x => x.GetParameters().Length).First();
|
||||
}
|
||||
|
||||
|
||||
DependencyTypeAttribute dependencyTypeAttribute = null;
|
||||
if (toType.IsDefined(typeof(DependencyTypeAttribute), true))
|
||||
{
|
||||
@@ -199,7 +199,7 @@ namespace TouchSocket.Core
|
||||
{
|
||||
var attribute = parameters[i].GetCustomAttribute<DependencyInjectAttribute>();
|
||||
var type = attribute.Type ?? parameters[i].ParameterType;
|
||||
ps[i] = this.Resolve(type,attribute.Key);
|
||||
ps[i] = this.Resolve(type, attribute.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TouchSocket.Core
|
||||
{
|
||||
@@ -15,7 +11,7 @@ namespace TouchSocket.Core
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
|
||||
|
||||
Constructor = 0,
|
||||
|
||||
/// <summary>
|
||||
@@ -28,4 +24,4 @@ namespace TouchSocket.Core
|
||||
/// </summary>
|
||||
Method = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TouchSocket.Core
|
||||
@@ -22,15 +22,15 @@ namespace TouchSocket.Core
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断指定的类型是否已在容器中注册。
|
||||
/// <para>
|
||||
/// 在本容器中,一般均会返回<see langword="true"/>。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="fromType"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// 判断指定的类型是否已在容器中注册。
|
||||
/// <para>
|
||||
/// 在本容器中,一般均会返回<see langword="true"/>。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="fromType"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool IsRegistered(Type fromType, string key = "")
|
||||
{
|
||||
return true;
|
||||
@@ -57,7 +57,7 @@ namespace TouchSocket.Core
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public object Resolve(Type fromType,string key = "")
|
||||
public object Resolve(Type fromType, string key = "")
|
||||
{
|
||||
if (fromType.FullName == "TouchSocket.Core.IContainer")
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace TouchSocket.Core
|
||||
/// <param name="instance"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual bool TryResolve(Type fromType, out object instance,string key = "")
|
||||
protected virtual bool TryResolve(Type fromType, out object instance, string key = "")
|
||||
{
|
||||
if (key.IsNullOrEmpty())
|
||||
{
|
||||
@@ -101,4 +101,4 @@ namespace TouchSocket.Core
|
||||
return this.m_singletonInstances.TryGetValue($"{fromType.FullName}{key}", out instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ namespace TouchSocket.Core
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> GetTupleElementNames(this ParameterInfo parameter)
|
||||
{
|
||||
return (IEnumerable<string>)DynamicMethodMemberAccessor.Default.GetValue(parameter.GetCustomAttribute(Type.GetType("System.Runtime.CompilerServices.TupleElementNamesAttribute")), "TransformNames");
|
||||
return (IEnumerable<string>)DynamicMethodMemberAccessor.Default.GetValue(parameter.GetCustomAttribute(Type.GetType("System.Runtime.CompilerServices.TupleElementNamesAttribute")), "TransformNames");
|
||||
//return ((dynamic)parameter.GetCustomAttribute(Type.GetType("System.Runtime.CompilerServices.TupleElementNamesAttribute")))?.TransformNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace TouchSocket.Core
|
||||
{
|
||||
if (rootPath is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(rootPath));
|
||||
throw new ArgumentNullException(nameof(rootPath));
|
||||
}
|
||||
this.m_rootPath = rootPath;
|
||||
this.m_rootPath = rootPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace TouchSocket.Core
|
||||
/// 打包所有的路由包信息。顺序为:先调用<see cref="PackageRouter(in ByteBlock)"/>,然后<see cref="PackageBody(in ByteBlock)"/>
|
||||
/// </summary>
|
||||
/// <param name="byteBlock"></param>
|
||||
public override sealed void Package(in ByteBlock byteBlock)
|
||||
public sealed override void Package(in ByteBlock byteBlock)
|
||||
{
|
||||
this.PackageRouter(byteBlock);
|
||||
this.PackageBody(byteBlock);
|
||||
@@ -74,7 +74,7 @@ namespace TouchSocket.Core
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override sealed void Unpackage(in ByteBlock byteBlock)
|
||||
public sealed override void Unpackage(in ByteBlock byteBlock)
|
||||
{
|
||||
this.UnpackageRouter(byteBlock);
|
||||
this.UnpackageBody(byteBlock);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace TouchSocket.Core
|
||||
|
||||
public Task Run(object sender, PluginEventArgs e)
|
||||
{
|
||||
return Method.InvokeAsync(this.Plugin, sender, e);
|
||||
return this.Method.InvokeAsync(this.Plugin, sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ namespace TouchSocket.Core
|
||||
|
||||
private List<string> SearchPluginMethod(IPlugin plugin)
|
||||
{
|
||||
List<string> pluginMethodNames = new List<string>();
|
||||
var pluginMethodNames = new List<string>();
|
||||
var pluginInterfacetypes = plugin.GetType().GetInterfaces().Where(a => typeof(IPlugin).IsAssignableFrom(a)).ToArray();
|
||||
foreach (var type in pluginInterfacetypes)
|
||||
{
|
||||
@@ -159,13 +159,13 @@ namespace TouchSocket.Core
|
||||
IPlugin plugin;
|
||||
if (this.m_container.IsRegistered(pluginType))
|
||||
{
|
||||
plugin = (IPlugin)this.m_container.Resolve(pluginType);
|
||||
plugin = (IPlugin)this.m_container.Resolve(pluginType);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin = (IPlugin)this.m_container.ResolveWithoutRoot(pluginType);
|
||||
}
|
||||
|
||||
|
||||
((IPluginsManager)this).Add(plugin);
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -1228,7 +1228,6 @@ namespace TouchSocket.Core
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 写入一个标识非Null值
|
||||
/// </summary>
|
||||
|
||||
@@ -54,16 +54,16 @@ namespace TouchSocket.Core
|
||||
/// 初始化一个动态调用方法
|
||||
/// </summary>
|
||||
/// <param name="method"></param>
|
||||
public Method(MethodInfo method):this(method,true)
|
||||
{
|
||||
|
||||
public Method(MethodInfo method) : this(method, true)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个动态调用方法
|
||||
/// </summary>
|
||||
/// <param name="method">方法信息</param>
|
||||
/// <param name="build">是否直接使用IL构建调用</param>
|
||||
public Method(MethodInfo method,bool build)
|
||||
public Method(MethodInfo method, bool build)
|
||||
{
|
||||
this.Info = method ?? throw new ArgumentNullException(nameof(method));
|
||||
this.Name = method.Name;
|
||||
@@ -268,7 +268,7 @@ namespace TouchSocket.Core
|
||||
case TaskReturnType.TaskObject:
|
||||
{
|
||||
Task task;
|
||||
if (GlobalEnvironment.DynamicBuilderType== DynamicBuilderType.Reflect)
|
||||
if (GlobalEnvironment.DynamicBuilderType == DynamicBuilderType.Reflect)
|
||||
{
|
||||
task = (Task)this.Info.Invoke(instance, parameters);
|
||||
}
|
||||
@@ -364,7 +364,7 @@ namespace TouchSocket.Core
|
||||
/// </summary>
|
||||
/// <param name="methodInfo"></param>
|
||||
/// <returns></returns>
|
||||
protected Func<object, object[], object> CreateILInvoker(MethodInfo methodInfo)
|
||||
protected Func<object, object[], object> CreateILInvoker(MethodInfo methodInfo)
|
||||
{
|
||||
var dynamicMethod = new DynamicMethod(string.Empty, typeof(object), new Type[] { typeof(object), typeof(object[])
|
||||
}, methodInfo.DeclaringType.Module);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace TouchSocket.Core
|
||||
#if !NET45
|
||||
if (obj.TryGetBuffer(out var array))
|
||||
{
|
||||
byteBlock.Write(array.Array,array.Offset,array.Count);
|
||||
byteBlock.Write(array.Array, array.Offset, array.Count);
|
||||
return array.Count;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TouchSocket.Core
|
||||
namespace TouchSocket.Core
|
||||
{
|
||||
internal class StringFastBinaryConverter : FastBinaryConverter<string>
|
||||
{
|
||||
@@ -24,4 +18,4 @@ namespace TouchSocket.Core
|
||||
return byteBlock.Pos - pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,12 @@ using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Runtime;
|
||||
using System.Text;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endif
|
||||
|
||||
|
||||
namespace TouchSocket.Core
|
||||
{
|
||||
/// <summary>
|
||||
@@ -35,6 +34,7 @@ namespace TouchSocket.Core
|
||||
/// </summary>
|
||||
public const DynamicallyAccessedMemberTypes DynamicallyAccessed = DynamicallyAccessedMemberTypes.All;
|
||||
#endif
|
||||
|
||||
static FastBinaryFormatter()
|
||||
{
|
||||
AddFastBinaryConverter(typeof(string), new StringFastBinaryConverter());
|
||||
@@ -54,6 +54,7 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void AddFastBinaryConverter<[DynamicallyAccessedMembers(DynamicallyAccessed)] TType, [DynamicallyAccessedMembers(DynamicallyAccessed)] TConverter>() where TConverter : IFastBinaryConverter, new()
|
||||
#else
|
||||
|
||||
public static void AddFastBinaryConverter<TType, TConverter>() where TConverter : IFastBinaryConverter, new()
|
||||
#endif
|
||||
|
||||
@@ -69,7 +70,8 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void AddFastBinaryConverter<[DynamicallyAccessedMembers(DynamicallyAccessed)] TType>(IFastBinaryConverter converter)
|
||||
#else
|
||||
public static void AddFastBinaryConverter<TType>(IFastBinaryConverter converter)
|
||||
|
||||
public static void AddFastBinaryConverter<TType>(IFastBinaryConverter converter)
|
||||
#endif
|
||||
{
|
||||
AddFastBinaryConverter(typeof(TType), converter);
|
||||
@@ -83,6 +85,7 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void AddFastBinaryConverter([DynamicallyAccessedMembers(DynamicallyAccessed)] Type type, IFastBinaryConverter converter)
|
||||
#else
|
||||
|
||||
public static void AddFastBinaryConverter(Type type, IFastBinaryConverter converter)
|
||||
#endif
|
||||
{
|
||||
@@ -100,7 +103,8 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void Serialize<[DynamicallyAccessedMembers(DynamicallyAccessed)] T>(ByteBlock byteBlock, [DynamicallyAccessedMembers(DynamicallyAccessed)] in T graph)
|
||||
#else
|
||||
public static void Serialize<T>(ByteBlock byteBlock,in T graph)
|
||||
|
||||
public static void Serialize<T>(ByteBlock byteBlock, in T graph)
|
||||
#endif
|
||||
{
|
||||
byteBlock.Position = 1;
|
||||
@@ -406,6 +410,7 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static object Deserialize(byte[] data, int offset, [DynamicallyAccessedMembers(DynamicallyAccessed)] Type type)
|
||||
#else
|
||||
|
||||
public static object Deserialize(byte[] data, int offset, Type type)
|
||||
#endif
|
||||
{
|
||||
|
||||
@@ -16,11 +16,11 @@ using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endif
|
||||
|
||||
|
||||
namespace TouchSocket.Core
|
||||
{
|
||||
/// <summary>
|
||||
@@ -193,6 +193,7 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void FastBinarySerialize<[DynamicallyAccessedMembers(FastBinaryFormatter.DynamicallyAccessed)] T>(ByteBlock stream, [DynamicallyAccessedMembers(FastBinaryFormatter.DynamicallyAccessed)] in T obj)
|
||||
#else
|
||||
|
||||
public static void FastBinarySerialize<T>(ByteBlock stream, in T obj)
|
||||
#endif
|
||||
{
|
||||
@@ -207,6 +208,7 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static byte[] FastBinarySerialize<[DynamicallyAccessedMembers(FastBinaryFormatter.DynamicallyAccessed)] T>([DynamicallyAccessedMembers(FastBinaryFormatter.DynamicallyAccessed)] in T obj)
|
||||
#else
|
||||
|
||||
public static byte[] FastBinarySerialize<T>(in T obj)
|
||||
#endif
|
||||
{
|
||||
@@ -231,6 +233,7 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static T FastBinaryDeserialize<[DynamicallyAccessedMembers(FastBinaryFormatter.DynamicallyAccessed)] T>(byte[] data, int offset)
|
||||
#else
|
||||
|
||||
public static T FastBinaryDeserialize<T>(byte[] data, int offset)
|
||||
#endif
|
||||
{
|
||||
@@ -247,6 +250,7 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static object FastBinaryDeserialize(byte[] data, int offset, [DynamicallyAccessedMembers(FastBinaryFormatter.DynamicallyAccessed)] Type type)
|
||||
#else
|
||||
|
||||
public static object FastBinaryDeserialize(byte[] data, int offset, Type type)
|
||||
#endif
|
||||
{
|
||||
@@ -262,6 +266,7 @@ namespace TouchSocket.Core
|
||||
#if NET6_0_OR_GREATER
|
||||
public static T FastBinaryDeserialize<[DynamicallyAccessedMembers(FastBinaryFormatter.DynamicallyAccessed)] T>(byte[] data)
|
||||
#else
|
||||
|
||||
public static T FastBinaryDeserialize<T>(byte[] data)
|
||||
#endif
|
||||
{
|
||||
|
||||
@@ -24,28 +24,23 @@
|
||||
// }
|
||||
|
||||
// public bool Wait(TimeSpan timeout)
|
||||
// {
|
||||
|
||||
// {
|
||||
// }
|
||||
// public bool Wait(TimeSpan timeout, CancellationToken cancellationToken)
|
||||
// {
|
||||
|
||||
// {
|
||||
// }
|
||||
// public bool Wait(int millisecondsTimeout)
|
||||
// {
|
||||
|
||||
// {
|
||||
// }
|
||||
// public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)
|
||||
// {
|
||||
|
||||
// {
|
||||
// }
|
||||
// public void Wait()
|
||||
// {
|
||||
|
||||
// {
|
||||
// }
|
||||
// public void Wait(CancellationToken cancellationToken); public void Dispose()
|
||||
// public Task WaitAsync(); {
|
||||
// public Task<bool> WaitAsync(int millisecondsTimeout);
|
||||
// public Task<bool> WaitAsync(int millisecondsTimeout);
|
||||
// public Task<bool> WaitAsync(TimeSpan timeout); }
|
||||
// } public Task<bool> WaitAsync(TimeSpan timeout, CancellationToken cancellationToken);
|
||||
//} public Task<bool> WaitAsync(int millisecondsTimeout, CancellationToken cancellationToken);
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace TouchSocket.Core
|
||||
private readonly AutoResetEvent m_waitHandle;
|
||||
private volatile WaitDataStatus m_status;
|
||||
private CancellationTokenRegistration m_tokenRegistration;
|
||||
|
||||
/// <summary>
|
||||
/// WaitData
|
||||
/// </summary>
|
||||
@@ -80,7 +81,7 @@ namespace TouchSocket.Core
|
||||
else
|
||||
{
|
||||
this.m_tokenRegistration.Dispose();
|
||||
this.m_tokenRegistration=cancellationToken.Register(this.Cancel);
|
||||
this.m_tokenRegistration = cancellationToken.Register(this.Cancel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +351,8 @@ namespace TouchSocket.Dmtp
|
||||
{
|
||||
this.OnCreatedChannel((CreateChannelEventArgs)obj);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion 委托触发
|
||||
|
||||
#region const
|
||||
|
||||
@@ -543,7 +544,6 @@ namespace TouchSocket.Dmtp
|
||||
|
||||
if (this.AllowRoute && waitPing.Route)
|
||||
{
|
||||
|
||||
if (await this.TryRoute(new PackageRouterEventArgs(RouteType.Ping, waitPing)).ConfigureFalseAwait())
|
||||
{
|
||||
if (await this.TryFindDmtpActor(waitPing.TargetId).ConfigureFalseAwait() is DmtpActor actor)
|
||||
@@ -945,7 +945,7 @@ namespace TouchSocket.Dmtp
|
||||
var waitPing = new WaitPing
|
||||
{
|
||||
TargetId = targetId,
|
||||
SourceId = Id,
|
||||
SourceId = this.Id,
|
||||
Route = targetId.HasValue()
|
||||
};
|
||||
var waitData = this.WaitHandlePool.GetWaitData(waitPing);
|
||||
@@ -986,7 +986,7 @@ namespace TouchSocket.Dmtp
|
||||
var waitPing = new WaitPing
|
||||
{
|
||||
TargetId = targetId,
|
||||
SourceId = Id,
|
||||
SourceId = this.Id,
|
||||
Route = targetId.HasValue()
|
||||
};
|
||||
var waitData = this.WaitHandlePool.GetWaitDataAsync(waitPing);
|
||||
@@ -1062,7 +1062,7 @@ namespace TouchSocket.Dmtp
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 重写
|
||||
#endregion 断开
|
||||
|
||||
#region 协议同步发送
|
||||
|
||||
@@ -1434,7 +1434,6 @@ namespace TouchSocket.Dmtp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion IDmtpChannel
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,6 @@ namespace TouchSocket.Dmtp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void PreviewSend(IRequestInfo requestInfo)
|
||||
{
|
||||
@@ -98,7 +97,6 @@ namespace TouchSocket.Dmtp
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
await this.m_locker.WaitAsync();
|
||||
foreach (var item in transferBytes)
|
||||
{
|
||||
@@ -121,7 +119,6 @@ namespace TouchSocket.Dmtp
|
||||
await this.GoSendAsync(byteBlock.Buffer, 0, byteBlock.Len);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -147,7 +144,6 @@ namespace TouchSocket.Dmtp
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
this.m_locker.Wait();
|
||||
foreach (var item in transferBytes)
|
||||
{
|
||||
|
||||
@@ -44,11 +44,11 @@ namespace TouchSocket.Dmtp
|
||||
this.m_dataQueue = new IntelligentDataQueue<ChannelPackage>(this.m_cacheCapacity)
|
||||
{
|
||||
OverflowWait = false,
|
||||
OnQueueChanged = OnQueueChanged
|
||||
OnQueueChanged = this.OnQueueChanged
|
||||
};
|
||||
this.m_canFree = true;
|
||||
this.m_maxSpeed = int.MaxValue;
|
||||
this.m_flowGate = new FlowGate() { Maximum = m_maxSpeed };
|
||||
this.m_flowGate = new FlowGate() { Maximum = this.m_maxSpeed };
|
||||
this.Metadata = metadata;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace TouchSocket.Dmtp
|
||||
private Func<string, Task<IDmtpActor>> m_findDmtpActor;
|
||||
private DmtpActor m_dmtpActor;
|
||||
private readonly SemaphoreSlim m_semaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
#endregion 字段
|
||||
|
||||
/// <inheritdoc cref="IDmtpActor.Id"/>
|
||||
@@ -210,6 +211,7 @@ namespace TouchSocket.Dmtp
|
||||
#endregion 连接
|
||||
|
||||
#region 断开
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
@@ -242,7 +244,7 @@ namespace TouchSocket.Dmtp
|
||||
await base.OnDisconnected(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion 断开
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override async Task ReceivedData(ReceivedDataEventArgs e)
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace TouchSocket.Dmtp
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (this.IsHandshaked)
|
||||
if (this.IsHandshaked)
|
||||
{
|
||||
this.m_dmtpActor?.SafeDispose();
|
||||
}
|
||||
|
||||
@@ -439,7 +439,6 @@ namespace TouchSocket.Dmtp
|
||||
{
|
||||
this.m_semaphoreForSend.Release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion 内部委托绑定
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace TouchSocket.Dmtp.FileTransfer
|
||||
{
|
||||
waitFileResource.UnpackageBody(byteBlock);
|
||||
|
||||
_=Task.Factory.StartNew(this.RequestPullFileResourceInfo, waitFileResource);
|
||||
_ = Task.Factory.StartNew(this.RequestPullFileResourceInfo, waitFileResource);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -400,7 +400,7 @@ namespace TouchSocket.Dmtp.FileTransfer
|
||||
else
|
||||
{
|
||||
waitSmallFilePackage.UnpackageBody(byteBlock);
|
||||
_=Task.Factory.StartNew(this.RequestPullSmallFile, waitSmallFilePackage);
|
||||
_ = Task.Factory.StartNew(this.RequestPullSmallFile, waitSmallFilePackage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -57,4 +57,4 @@
|
||||
// this.Length = len;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
@@ -27,6 +27,7 @@ namespace TouchSocket.Dmtp.Redis
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ICache<string, byte[]> ICache { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int Timeout { get; set; } = 30 * 1000;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Resources;
|
||||
|
||||
@@ -26,11 +26,19 @@ namespace TouchSocket.Dmtp.Rpc
|
||||
/// <para>是否仅以函数名调用,当为True是,调用时仅需要传入方法名即可。</para>
|
||||
/// </summary>
|
||||
/// <param name="methodInvoke"></param>
|
||||
public DmtpRpcAttribute(bool methodInvoke = false)
|
||||
public DmtpRpcAttribute(bool methodInvoke)
|
||||
{
|
||||
this.MethodInvoke = methodInvoke;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 适用于DmtpRpc的标记
|
||||
/// </summary>
|
||||
public DmtpRpcAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 适用于DmtpRpc的标记.
|
||||
/// </summary>
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace TouchSocket.Dmtp.Rpc
|
||||
/// <typeparam name="TAttribute"></typeparam>
|
||||
public abstract class DmtpRpcDispatchProxy<TClient, TAttribute> : RpcDispatchProxy<TClient, TAttribute> where TClient : IDmtpRpcActor where TAttribute : DmtpRpcAttribute
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -24,8 +24,8 @@ namespace TouchSocket.Dmtp.Rpc
|
||||
/// </summary>
|
||||
/// <typeparam name="TClient"></typeparam>
|
||||
public abstract class DmtpRpcDispatchProxy<TClient> : DmtpRpcDispatchProxy<TClient, DmtpRpcAttribute> where TClient : IDmtpRpcActor
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -40,10 +40,7 @@ namespace TouchSocket.Dmtp.Rpc
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_tokenSource == null)
|
||||
{
|
||||
this.m_tokenSource = new CancellationTokenSource();
|
||||
}
|
||||
this.m_tokenSource ??= new CancellationTokenSource();
|
||||
return this.m_tokenSource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace TouchSocket.Dmtp
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
public Func<string, Task<IDmtpActor>> FindDmtpActor { get ; set ; }
|
||||
public Func<string, Task<IDmtpActor>> FindDmtpActor { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,6 @@ namespace TouchSocket.Http
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override Task ReceivedData(ReceivedDataEventArgs e)
|
||||
{
|
||||
|
||||
@@ -394,8 +394,8 @@ namespace TouchSocket.Http
|
||||
/// <returns></returns>
|
||||
public static TResponse UrlNotFind<TResponse>(this TResponse response) where TResponse : HttpResponse
|
||||
{
|
||||
response.SetContent("<html><body><h1>404 -RRQM Not Found</h1></body></html>");
|
||||
response.StatusCode = 404;
|
||||
response.SetContent("<html><body><h1>404 -Not Found</h1></body></html>");
|
||||
response.SetStatus(404, "Not Found");
|
||||
response.ContentType = "text/html;charset=utf-8";
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
|
||||
public Task PingAsync()
|
||||
{
|
||||
return this.m_client.PingWSAsync();
|
||||
return this.m_client.PingWSAsync();
|
||||
}
|
||||
|
||||
public void Pong()
|
||||
@@ -57,7 +57,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
|
||||
public Task PongAsync()
|
||||
{
|
||||
return this.m_client.PongWSAsync();
|
||||
return this.m_client.PongWSAsync();
|
||||
}
|
||||
|
||||
public async Task<WebSocketReceiveResult> ReadAsync(CancellationToken token)
|
||||
@@ -69,6 +69,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
await this.m_resetEventForRead.WaitOneAsync(token).ConfigureFalseAwait();
|
||||
return new WebSocketReceiveResult(this.ComplateRead, this.m_dataFrame);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
public async ValueTask<WebSocketReceiveResult> ValueReadAsync(CancellationToken token)
|
||||
{
|
||||
@@ -80,7 +81,9 @@ namespace TouchSocket.Http.WebSockets
|
||||
return new WebSocketReceiveResult(this.ComplateRead, this.m_dataFrame);
|
||||
}
|
||||
#endif
|
||||
|
||||
#region 发送
|
||||
|
||||
public void Send(WSDataFrame dataFrame, bool endOfMessage = true)
|
||||
{
|
||||
this.m_client.SendWithWS(dataFrame, endOfMessage);
|
||||
@@ -126,7 +129,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
return this.m_client.SendWithWSAsync(dataFrame, endOfMessage);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion 发送
|
||||
|
||||
public async Task<bool> TryInputReceiveAsync(WSDataFrame dataFrame)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace TouchSocket.Http.WebSockets
|
||||
{
|
||||
@@ -25,11 +20,10 @@ namespace TouchSocket.Http.WebSockets
|
||||
this.DataFrame = dataFrame;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
m_disAction?.Invoke();
|
||||
this.m_disAction?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,4 +36,4 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// </summary>
|
||||
public bool IsClosed => this.DataFrame == null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,10 +211,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
{
|
||||
case FilterResult.Cache:
|
||||
{
|
||||
if (this.m_tempByteBlock == null)
|
||||
{
|
||||
this.m_tempByteBlock = new ByteBlock();
|
||||
}
|
||||
this.m_tempByteBlock ??= new ByteBlock();
|
||||
this.m_tempByteBlock.Write(dataBuffer, offset, length - offset);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,13 +42,13 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <summary>
|
||||
/// 获取显式WebSocket终端。
|
||||
/// <para>
|
||||
///
|
||||
///
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="allowReceive"></param>
|
||||
/// <returns></returns>
|
||||
public static IWebSocket GetWebSocket(this IHttpClientBase client,bool allowReceive=true)
|
||||
public static IWebSocket GetWebSocket(this IHttpClientBase client, bool allowReceive = true)
|
||||
{
|
||||
var websocket = client.GetValue(WebSocketProperty);
|
||||
if (websocket == null)
|
||||
@@ -67,7 +67,9 @@ namespace TouchSocket.Http.WebSockets
|
||||
{
|
||||
client.RemoveValue(WebSocketProperty);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion DependencyProperty
|
||||
|
||||
/// <summary>
|
||||
/// 发送Close报文。
|
||||
/// </summary>
|
||||
@@ -166,7 +168,6 @@ namespace TouchSocket.Http.WebSockets
|
||||
|
||||
#region 同步发送
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 采用WebSocket协议,发送二进制流数据。
|
||||
/// </summary>
|
||||
@@ -177,7 +178,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <param name="length"></param>
|
||||
public static void SendWithWS(this IHttpClientBase client, byte[] buffer, int offset, int length, bool endOfMessage = true)
|
||||
{
|
||||
using (var frame = new WSDataFrame() { FIN = endOfMessage, Opcode = WSDataType.Binary })
|
||||
using (var frame = new WSDataFrame() { FIN = endOfMessage, Opcode = WSDataType.Binary })
|
||||
{
|
||||
if (offset == 0)
|
||||
{
|
||||
@@ -187,7 +188,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
{
|
||||
frame.AppendBinary(buffer, offset, length);
|
||||
}
|
||||
SendWithWS(client, frame,endOfMessage);
|
||||
SendWithWS(client, frame, endOfMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,10 +200,10 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <param name="endOfMessage"></param>
|
||||
public static void SendWithWS(this IHttpClientBase client, ByteBlock byteBlock, bool endOfMessage = true)
|
||||
{
|
||||
using (var frame = new WSDataFrame() { FIN = endOfMessage, Opcode = WSDataType.Binary })
|
||||
using (var frame = new WSDataFrame() { FIN = endOfMessage, Opcode = WSDataType.Binary })
|
||||
{
|
||||
frame.PayloadData = byteBlock;
|
||||
SendWithWS(client, frame,endOfMessage);
|
||||
SendWithWS(client, frame, endOfMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,9 +226,9 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <param name="endOfMessage"></param>
|
||||
public static void SendWithWS(this IHttpClientBase client, string text, bool endOfMessage = true)
|
||||
{
|
||||
using (var frame = new WSDataFrame() { FIN = endOfMessage, Opcode = WSDataType.Text }.AppendText(text))
|
||||
using (var frame = new WSDataFrame() { FIN = endOfMessage, Opcode = WSDataType.Text }.AppendText(text))
|
||||
{
|
||||
SendWithWS(client, frame,endOfMessage);
|
||||
SendWithWS(client, frame, endOfMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +238,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <param name="client"></param>
|
||||
/// <param name="dataFrame"></param>
|
||||
/// <param name="endOfMessage"></param>
|
||||
public static void SendWithWS(this IHttpClientBase client, WSDataFrame dataFrame,bool endOfMessage=true)
|
||||
public static void SendWithWS(this IHttpClientBase client, WSDataFrame dataFrame, bool endOfMessage = true)
|
||||
{
|
||||
var isCont = client.GetIsCont();
|
||||
|
||||
@@ -287,7 +288,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <param name="length"></param>
|
||||
public static Task SendWithWSAsync(this IHttpClientBase client, byte[] buffer, int offset, int length, bool endOfMessage = true)
|
||||
{
|
||||
using (var frame = new WSDataFrame() { FIN = endOfMessage, Opcode = WSDataType.Binary })
|
||||
using (var frame = new WSDataFrame() { FIN = endOfMessage, Opcode = WSDataType.Binary })
|
||||
{
|
||||
if (offset == 0)
|
||||
{
|
||||
@@ -297,7 +298,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
{
|
||||
frame.AppendBinary(buffer, offset, length);
|
||||
}
|
||||
return SendWithWSAsync(client, frame,endOfMessage);
|
||||
return SendWithWSAsync(client, frame, endOfMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +321,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <param name="endOfMessage"></param>
|
||||
public static Task SendWithWSAsync(this IHttpClientBase client, string text, bool endOfMessage = true)
|
||||
{
|
||||
using (var frame = new WSDataFrame() { FIN = true, Opcode = WSDataType.Text }.AppendText(text))
|
||||
using (var frame = new WSDataFrame() { FIN = true, Opcode = WSDataType.Text }.AppendText(text))
|
||||
{
|
||||
return SendWithWSAsync(client, frame, endOfMessage);
|
||||
}
|
||||
@@ -332,7 +333,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <param name="client"></param>
|
||||
/// <param name="dataFrame"></param>
|
||||
/// <param name="endOfMessage"></param>
|
||||
public static Task SendWithWSAsync(this IHttpClientBase client, WSDataFrame dataFrame,bool endOfMessage=true)
|
||||
public static Task SendWithWSAsync(this IHttpClientBase client, WSDataFrame dataFrame, bool endOfMessage = true)
|
||||
{
|
||||
var isCont = client.GetIsCont();
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<WebSocketReceiveResult> ReadAsync(CancellationToken token);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// 值异步等待读取数据
|
||||
@@ -69,6 +70,7 @@ namespace TouchSocket.Http.WebSockets
|
||||
/// <returns></returns>
|
||||
public ValueTask<WebSocketReceiveResult> ValueReadAsync(CancellationToken token);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 采用WebSocket协议,发送WS数据。发送结束后,请及时释放<see cref="WSDataFrame"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -101,9 +101,11 @@ namespace TouchSocket.Http.WebSockets
|
||||
await method.InvokeAsync(this, os);
|
||||
result = default;
|
||||
break;
|
||||
|
||||
case TaskReturnType.TaskObject:
|
||||
result = await method.InvokeObjectAsync(this, os);
|
||||
break;
|
||||
|
||||
case TaskReturnType.None:
|
||||
default:
|
||||
result = method.Invoke(this, os);
|
||||
|
||||
@@ -26,11 +26,19 @@ namespace TouchSocket.JsonRpc
|
||||
/// <para>是否仅以函数名调用,当为True是,调用时仅需要传入方法名即可。</para>
|
||||
/// </summary>
|
||||
/// <param name="methodInvoke"></param>
|
||||
public JsonRpcAttribute(bool methodInvoke = false)
|
||||
public JsonRpcAttribute(bool methodInvoke)
|
||||
{
|
||||
this.MethodInvoke = methodInvoke;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 适用于JsonRpc的标记
|
||||
/// </summary>
|
||||
public JsonRpcAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 适用于JsonRpc的标记.
|
||||
/// </summary>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace TouchSocket.JsonRpc
|
||||
/// <summary>
|
||||
/// JsonRpcErrorResponse
|
||||
/// </summary>
|
||||
public class JsonRpcErrorResponse: JsonRpcResponseBase
|
||||
public class JsonRpcErrorResponse : JsonRpcResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
/// error
|
||||
@@ -26,6 +26,7 @@ namespace TouchSocket.JsonRpc
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("error")]
|
||||
#endif
|
||||
|
||||
[JsonProperty("error")]
|
||||
public JsonRpcError Error { get; set; }
|
||||
}
|
||||
|
||||
@@ -24,36 +24,24 @@ namespace TouchSocket.JsonRpc
|
||||
/// jsonrpc
|
||||
/// </summary>
|
||||
[JsonProperty("jsonrpc")]
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("jsonrpc")]
|
||||
#endif
|
||||
public string Jsonrpc { get; set; } = "2.0";
|
||||
|
||||
/// <summary>
|
||||
/// method
|
||||
/// </summary>
|
||||
[JsonProperty("method")]
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("method")]
|
||||
#endif
|
||||
public string Method { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// @params
|
||||
/// </summary>
|
||||
[JsonProperty("params")]
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("params")]
|
||||
#endif
|
||||
public object Params { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// id
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("id")]
|
||||
#endif
|
||||
public long? Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace TouchSocket.JsonRpc
|
||||
{
|
||||
/// <summary>
|
||||
@@ -23,9 +22,6 @@ namespace TouchSocket.JsonRpc
|
||||
/// parameters
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
#endif
|
||||
public object[] Parameters { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TouchSocket.JsonRpc
|
||||
{
|
||||
@@ -18,17 +13,18 @@ namespace TouchSocket.JsonRpc
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("jsonrpc")]
|
||||
#endif
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; } = "2.0";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// id
|
||||
/// </summary>
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("id")]
|
||||
#endif
|
||||
|
||||
[JsonProperty("id")]
|
||||
public long? Id { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,14 +12,13 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace TouchSocket.JsonRpc
|
||||
{
|
||||
/// <summary>
|
||||
/// JsonRpc响应器
|
||||
/// </summary>
|
||||
public class JsonRpcResponseContext:JsonRpcResponseBase
|
||||
public class JsonRpcResponseContext : JsonRpcResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
/// result
|
||||
@@ -27,6 +26,7 @@ namespace TouchSocket.JsonRpc
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("result")]
|
||||
#endif
|
||||
|
||||
[JsonProperty("result")]
|
||||
public object Result { get; set; }
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace TouchSocket.JsonRpc
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("error")]
|
||||
#endif
|
||||
|
||||
[JsonProperty("error")]
|
||||
public JsonRpcError Error { get; set; }
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace TouchSocket.JsonRpc
|
||||
/// <summary>
|
||||
/// JsonRpcSuccessResponse
|
||||
/// </summary>
|
||||
public class JsonRpcSuccessResponse: JsonRpcResponseBase
|
||||
public class JsonRpcSuccessResponse : JsonRpcResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
/// result
|
||||
@@ -26,6 +26,7 @@ namespace TouchSocket.JsonRpc
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("result")]
|
||||
#endif
|
||||
|
||||
[JsonProperty("result")]
|
||||
public object Result { get; set; }
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Rpc;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace TouchSocket.JsonRpc
|
||||
{
|
||||
@@ -40,7 +39,6 @@ namespace TouchSocket.JsonRpc
|
||||
#else
|
||||
return jsonString.FromJsonString<JsonRpcWaitResult>();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +69,6 @@ namespace TouchSocket.JsonRpc
|
||||
#else
|
||||
return JsonConvert.SerializeObject(response);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -80,7 +77,7 @@ namespace TouchSocket.JsonRpc
|
||||
/// <param name="result"></param>
|
||||
/// <param name="returnType"></param>
|
||||
/// <returns></returns>
|
||||
public static object ResultParseToType(object result,Type returnType)
|
||||
public static object ResultParseToType(object result, Type returnType)
|
||||
{
|
||||
if (returnType.IsPrimitive || returnType == typeof(string))
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace TouchSocket.JsonRpc
|
||||
/// <summary>
|
||||
/// JsonRpcWaitResult
|
||||
/// </summary>
|
||||
public class JsonRpcWaitResult : JsonRpcResponseBase,IWaitResult
|
||||
public class JsonRpcWaitResult : JsonRpcResponseBase, IWaitResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Result
|
||||
@@ -26,6 +26,7 @@ namespace TouchSocket.JsonRpc
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("result")]
|
||||
#endif
|
||||
|
||||
[JsonProperty("result")]
|
||||
public object Result { get; set; }
|
||||
|
||||
@@ -35,29 +36,32 @@ namespace TouchSocket.JsonRpc
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonPropertyName("error")]
|
||||
#endif
|
||||
|
||||
[JsonProperty("error")]
|
||||
public JsonRpcError Error { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
#endif
|
||||
|
||||
[JsonIgnore]
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
#endif
|
||||
|
||||
[JsonIgnore]
|
||||
public string Message { get ; set ; }
|
||||
public long Sign { get => (long)this.Id; set => this.Id = value; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
#endif
|
||||
[JsonIgnore]
|
||||
public long Sign { get=> (long)this.Id ; set=>this.Id=value ; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET6_0_OR_GREATER
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
#endif
|
||||
[JsonIgnore]
|
||||
public byte Status { get ; set ; }
|
||||
public byte Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace TouchSocket.JsonRpc
|
||||
@@ -18,12 +14,12 @@ namespace TouchSocket.JsonRpc
|
||||
|
||||
protected override void SendJsonString(string jsonString)
|
||||
{
|
||||
m_client.Send(jsonString);
|
||||
this.m_client.Send(jsonString);
|
||||
}
|
||||
|
||||
protected override Task SendJsonStringAsync(string jsonString)
|
||||
{
|
||||
return m_client.SendAsync(jsonString);
|
||||
return this.m_client.SendAsync(jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Http;
|
||||
using TouchSocket.Http.WebSockets;
|
||||
@@ -20,14 +17,15 @@ namespace TouchSocket.JsonRpc
|
||||
}
|
||||
this.m_client = client;
|
||||
}
|
||||
|
||||
protected override void SendJsonString(string jsonString)
|
||||
{
|
||||
m_client.SendWithWS(jsonString);
|
||||
this.m_client.SendWithWS(jsonString);
|
||||
}
|
||||
|
||||
protected override Task SendJsonStringAsync(string jsonString)
|
||||
{
|
||||
return m_client.SendWithWSAsync(jsonString);
|
||||
return this.m_client.SendWithWSAsync(jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -397,8 +397,6 @@ namespace TouchSocket.JsonRpc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override Task ReceivedData(ReceivedDataEventArgs e)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Http.WebSockets;
|
||||
@@ -82,6 +81,7 @@ namespace TouchSocket.JsonRpc
|
||||
throw new TimeoutException("等待结果超时");
|
||||
case WaitDataStatus.Canceled:
|
||||
return default;
|
||||
|
||||
case WaitDataStatus.Default:
|
||||
case WaitDataStatus.Disposed:
|
||||
default:
|
||||
@@ -147,6 +147,7 @@ namespace TouchSocket.JsonRpc
|
||||
throw new TimeoutException("等待结果超时");
|
||||
case WaitDataStatus.Canceled:
|
||||
return;
|
||||
|
||||
case WaitDataStatus.Default:
|
||||
case WaitDataStatus.Disposed:
|
||||
default:
|
||||
@@ -224,6 +225,7 @@ namespace TouchSocket.JsonRpc
|
||||
throw new TimeoutException("等待结果超时");
|
||||
case WaitDataStatus.Canceled:
|
||||
return;
|
||||
|
||||
case WaitDataStatus.Default:
|
||||
case WaitDataStatus.Disposed:
|
||||
default:
|
||||
@@ -297,6 +299,7 @@ namespace TouchSocket.JsonRpc
|
||||
throw new TimeoutException("等待结果超时");
|
||||
case WaitDataStatus.Canceled:
|
||||
return default;
|
||||
|
||||
case WaitDataStatus.Default:
|
||||
case WaitDataStatus.Disposed:
|
||||
default:
|
||||
@@ -333,7 +336,6 @@ namespace TouchSocket.JsonRpc
|
||||
/// </summary>
|
||||
public ActionMap ActionMap { get; private set; } = new ActionMap(true);
|
||||
|
||||
|
||||
void IRpcParser.OnRegisterServer(MethodInstance[] methodInstances)
|
||||
{
|
||||
foreach (var methodInstance in methodInstances)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Http;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
@@ -54,7 +53,7 @@ namespace TouchSocket.JsonRpc
|
||||
return actionClient;
|
||||
}
|
||||
|
||||
if (socketClient.Protocol== Sockets.Protocol.Tcp)
|
||||
if (socketClient.Protocol == Sockets.Protocol.Tcp)
|
||||
{
|
||||
actionClient = new TcpServerJsonRpcClient(socketClient);
|
||||
socketClient.SetValue(JsonRpcActionClientProperty, actionClient);
|
||||
@@ -70,7 +69,6 @@ namespace TouchSocket.JsonRpc
|
||||
{
|
||||
throw new System.Exception("SocketClient必须是Tcp协议,或者完成WebSocket连接");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace TouchSocket.JsonRpc
|
||||
{
|
||||
@@ -23,4 +18,4 @@ namespace TouchSocket.JsonRpc
|
||||
/// <param name="jsonString"></param>
|
||||
void InputResponseString(string jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace TouchSocket.JsonRpc
|
||||
/// <summary>
|
||||
/// 基于Tcp协议的JsonRpc客户端。
|
||||
/// </summary>
|
||||
public interface ITcpJsonRpcClient : IJsonRpcClient, ITcpClient,IRpcParser
|
||||
public interface ITcpJsonRpcClient : IJsonRpcClient, ITcpClient, IRpcParser
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Http;
|
||||
|
||||
@@ -20,7 +19,7 @@ namespace TouchSocket.JsonRpc
|
||||
/// <param name="pluginsManager"></param>
|
||||
public HttpJsonRpcParserPlugin(IContainer container, IPluginsManager pluginsManager) : base(container)
|
||||
{
|
||||
pluginsManager.Add<IHttpSocketClient, HttpContextEventArgs>(nameof(IHttpPlugin.OnHttpRequest), OnHttpRequest);
|
||||
pluginsManager.Add<IHttpSocketClient, HttpContextEventArgs>(nameof(IHttpPlugin.OnHttpRequest), this.OnHttpRequest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,7 +43,7 @@ namespace TouchSocket.JsonRpc
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override sealed void Response(JsonRpcCallContextBase callContext, object result, JsonRpcError error)
|
||||
protected sealed override void Response(JsonRpcCallContextBase callContext, object result, JsonRpcError error)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -11,12 +11,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Rpc;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace TouchSocket.JsonRpc
|
||||
{
|
||||
@@ -39,7 +37,7 @@ namespace TouchSocket.JsonRpc
|
||||
{
|
||||
this.RpcStore = new RpcStore(container);
|
||||
}
|
||||
|
||||
|
||||
this.ActionMap = new ActionMap(true);
|
||||
this.RpcStore.AddRpcParser(this);
|
||||
}
|
||||
@@ -49,7 +47,6 @@ namespace TouchSocket.JsonRpc
|
||||
/// </summary>
|
||||
public ActionMap ActionMap { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
@@ -61,7 +58,7 @@ namespace TouchSocket.JsonRpc
|
||||
/// <param name="callContext"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <param name="error"></param>
|
||||
protected abstract void Response(JsonRpcCallContextBase callContext, object result,JsonRpcError error);
|
||||
protected abstract void Response(JsonRpcCallContextBase callContext, object result, JsonRpcError error);
|
||||
|
||||
/// <summary>
|
||||
/// 调用JsonRpc
|
||||
@@ -73,7 +70,7 @@ namespace TouchSocket.JsonRpc
|
||||
|
||||
try
|
||||
{
|
||||
JsonRpcUtility.BuildRequestContext(this.ActionMap,ref callContext);
|
||||
JsonRpcUtility.BuildRequestContext(this.ActionMap, ref callContext);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -111,6 +108,7 @@ namespace TouchSocket.JsonRpc
|
||||
var error = JsonRpcUtility.GetJsonRpcError(invokeResult);
|
||||
this.Response(callContext, invokeResult.Result, error);
|
||||
}
|
||||
|
||||
#region Rpc解析器
|
||||
|
||||
void IRpcParser.OnRegisterServer(MethodInstance[] methodInstances)
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace TouchSocket.JsonRpc
|
||||
/// <param name="pluginsManager"></param>
|
||||
public TcpJsonRpcParserPlugin(IContainer container, IPluginsManager pluginsManager) : base(container)
|
||||
{
|
||||
pluginsManager.Add<ITcpClientBase, ConnectedEventArgs>(nameof(ITcpConnectedPlugin.OnTcpConnected), OnTcpConnected);
|
||||
pluginsManager.Add<ITcpClientBase, ReceivedDataEventArgs>(nameof(ITcpReceivedPlugin.OnTcpReceived), OnTcpReceived);
|
||||
pluginsManager.Add<ITcpClientBase, ConnectedEventArgs>(nameof(ITcpConnectedPlugin.OnTcpConnected), this.OnTcpConnected);
|
||||
pluginsManager.Add<ITcpClientBase, ReceivedDataEventArgs>(nameof(ITcpReceivedPlugin.OnTcpReceived), this.OnTcpReceived);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,7 +38,7 @@ namespace TouchSocket.JsonRpc
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override sealed void Response(JsonRpcCallContextBase callContext, object result, JsonRpcError error)
|
||||
protected sealed override void Response(JsonRpcCallContextBase callContext, object result, JsonRpcError error)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace TouchSocket.JsonRpc
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override sealed void Response(JsonRpcCallContextBase callContext, object result, JsonRpcError error)
|
||||
protected sealed override void Response(JsonRpcCallContextBase callContext, object result, JsonRpcError error)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Pipes;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Principal;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -55,11 +54,13 @@ namespace TouchSocket.NamedPipe
|
||||
}
|
||||
|
||||
#region 变量
|
||||
|
||||
private int m_receiveBufferSize = 1024 * 10;
|
||||
private volatile bool m_online;
|
||||
private NamedPipeClientStream m_pipeStream;
|
||||
private ValueCounter m_receiveCounter;
|
||||
private SemaphoreSlim m_semaphoreSlimForConnect = new SemaphoreSlim(1, 1);
|
||||
|
||||
#endregion 变量
|
||||
|
||||
#region 事件
|
||||
@@ -158,7 +159,6 @@ namespace TouchSocket.NamedPipe
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (this.Disconnected != null)
|
||||
{
|
||||
await this.Disconnected.Invoke(this, e);
|
||||
@@ -205,6 +205,7 @@ namespace TouchSocket.NamedPipe
|
||||
#endregion 事件
|
||||
|
||||
#region 属性
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int ReceiveBufferSize => this.m_receiveBufferSize;
|
||||
|
||||
@@ -444,7 +445,7 @@ namespace TouchSocket.NamedPipe
|
||||
this.m_receiver = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Receiver
|
||||
|
||||
private void OnPeriod(long value)
|
||||
{
|
||||
|
||||
@@ -476,7 +476,7 @@ namespace TouchSocket.NamedPipe
|
||||
/// </summary>
|
||||
/// <param name="socketClient"></param>
|
||||
/// <param name="e"></param>
|
||||
protected override sealed Task OnClientConnected(INamedPipeSocketClient socketClient, ConnectedEventArgs e)
|
||||
protected sealed override Task OnClientConnected(INamedPipeSocketClient socketClient, ConnectedEventArgs e)
|
||||
{
|
||||
return this.OnConnected((TClient)socketClient, e);
|
||||
}
|
||||
@@ -486,7 +486,7 @@ namespace TouchSocket.NamedPipe
|
||||
/// </summary>
|
||||
/// <param name="socketClient"></param>
|
||||
/// <param name="e"></param>
|
||||
protected override sealed Task OnClientConnecting(INamedPipeSocketClient socketClient, ConnectingEventArgs e)
|
||||
protected sealed override Task OnClientConnecting(INamedPipeSocketClient socketClient, ConnectingEventArgs e)
|
||||
{
|
||||
return this.OnConnecting((TClient)socketClient, e);
|
||||
}
|
||||
@@ -496,7 +496,7 @@ namespace TouchSocket.NamedPipe
|
||||
/// </summary>
|
||||
/// <param name="socketClient"></param>
|
||||
/// <param name="e"></param>
|
||||
protected override sealed Task OnClientDisconnected(INamedPipeSocketClient socketClient, DisconnectEventArgs e)
|
||||
protected sealed override Task OnClientDisconnected(INamedPipeSocketClient socketClient, DisconnectEventArgs e)
|
||||
{
|
||||
return this.OnDisconnected((TClient)socketClient, e);
|
||||
}
|
||||
@@ -506,7 +506,7 @@ namespace TouchSocket.NamedPipe
|
||||
/// </summary>
|
||||
/// <param name="socketClient"></param>
|
||||
/// <param name="e"></param>
|
||||
protected override sealed Task OnClientDisconnecting(INamedPipeSocketClient socketClient, DisconnectEventArgs e)
|
||||
protected sealed override Task OnClientDisconnecting(INamedPipeSocketClient socketClient, DisconnectEventArgs e)
|
||||
{
|
||||
return this.OnDisconnecting((TClient)socketClient, e);
|
||||
}
|
||||
@@ -516,7 +516,7 @@ namespace TouchSocket.NamedPipe
|
||||
/// </summary>
|
||||
/// <param name="socketClient"></param>
|
||||
/// <param name="e"></param>
|
||||
protected override sealed Task OnClientReceivedData(INamedPipeSocketClient socketClient, ReceivedDataEventArgs e)
|
||||
protected sealed override Task OnClientReceivedData(INamedPipeSocketClient socketClient, ReceivedDataEventArgs e)
|
||||
{
|
||||
return this.OnReceived((TClient)socketClient, e);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace TouchSocket.NamedPipe
|
||||
return this.OnClientDisconnecting(socketClient, e);
|
||||
}
|
||||
|
||||
internal Task OnInternalReceivedData(INamedPipeSocketClient socketClient,ReceivedDataEventArgs e)
|
||||
internal Task OnInternalReceivedData(INamedPipeSocketClient socketClient, ReceivedDataEventArgs e)
|
||||
{
|
||||
return this.OnClientReceivedData(socketClient, e);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ namespace TouchSocket.NamedPipe
|
||||
/// </summary>
|
||||
/// <param name="socketClient"></param>
|
||||
/// <param name="e"></param>
|
||||
protected abstract Task OnClientReceivedData(INamedPipeSocketClient socketClient,ReceivedDataEventArgs e);
|
||||
protected abstract Task OnClientReceivedData(INamedPipeSocketClient socketClient, ReceivedDataEventArgs e);
|
||||
|
||||
#region Id发送
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace TouchSocket.NamedPipe
|
||||
private NamedPipeServerStream m_pipeStream;
|
||||
private ValueCounter m_receiveCounter;
|
||||
private int m_receiveBufferSize = 1024 * 10;
|
||||
|
||||
#endregion 字段
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
|
||||
@@ -94,4 +91,4 @@ namespace TouchSocket.NamedPipe
|
||||
|
||||
#endregion 连接
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.NamedPipe.Plugins;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace TouchSocket.NamedPipe
|
||||
{
|
||||
@@ -145,6 +144,5 @@ namespace TouchSocket.NamedPipe
|
||||
pluginsManager.Add(reconnectionPlugin);
|
||||
return reconnectionPlugin;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace TouchSocket.NamedPipe
|
||||
@@ -32,4 +27,4 @@ namespace TouchSocket.NamedPipe
|
||||
return service;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.NamedPipe;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace TouchSocket.NamedPipe.Plugins
|
||||
@@ -22,6 +18,7 @@ namespace TouchSocket.NamedPipe.Plugins
|
||||
pluginsManager.Add<object, ConfigEventArgs>(nameof(ILoadedConfigPlugin.OnLoadedConfig), this.OnLoadedConfig);
|
||||
pluginsManager.Add<NamedPipeClientBase, DisconnectEventArgs>(nameof(INamedPipeDisconnectedPlugin.OnNamedPipeDisconnected), this.OnNamedPipeDisconnected);
|
||||
}
|
||||
|
||||
private bool m_polling;
|
||||
|
||||
/// <summary>
|
||||
@@ -153,4 +150,4 @@ namespace TouchSocket.NamedPipe.Plugins
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace TouchSocket.Rpc
|
||||
/// 标识该接口方法将自动生成调用的扩展方法
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
|
||||
[Obsolete("此配置已被弃用,要使用源生成Rpc,请使用对应的Rpc特性,例如:DmtpRpc",true)]
|
||||
public sealed class GeneratorRpcMethodAttribute : RpcAttribute
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace TouchSocket.Rpc
|
||||
{
|
||||
/// <summary>
|
||||
/// 标识该接口将自动生成调用的代理类
|
||||
/// 标识该接口将使用源生成自动生成调用的代理类
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class GeneratorRpcProxyAttribute : Attribute
|
||||
|
||||
@@ -784,7 +784,6 @@ namespace TouchSocket.Rpc
|
||||
codeString.AppendLine("}");
|
||||
}
|
||||
|
||||
|
||||
return codeString.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ namespace TouchSocket.Rpc
|
||||
var attributes = method.GetCustomAttributes<RpcAttribute>(true);
|
||||
if (attributes.Any())
|
||||
{
|
||||
instances.Add(new MethodInstance(method,serverFromType,serverToType));
|
||||
instances.Add(new MethodInstance(method, serverFromType, serverToType));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace TouchSocket.Rpc
|
||||
// }
|
||||
//}
|
||||
|
||||
if (this.Parameters.Length>0&& typeof(ICallContext).IsAssignableFrom(this.Parameters[0].ParameterType))
|
||||
if (this.Parameters.Length > 0 && typeof(ICallContext).IsAssignableFrom(this.Parameters[0].ParameterType))
|
||||
{
|
||||
this.IncludeCallContext = true;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ namespace TouchSocket.Rpc
|
||||
/// <summary>
|
||||
/// 是否包含调用上下文
|
||||
/// </summary>
|
||||
public bool IncludeCallContext { get;private set; }
|
||||
public bool IncludeCallContext { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 筛选器
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace TouchSocket.Rpc
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
/// <param name="logger"></param>
|
||||
public RpcServerFactory(IContainer container,ILog logger)
|
||||
public RpcServerFactory(IContainer container, ILog logger)
|
||||
{
|
||||
this.m_container = container;
|
||||
this.m_logger = logger;
|
||||
|
||||
@@ -501,7 +501,6 @@ namespace TouchSocket.Rpc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (typeof(ITransientRpcServer).IsAssignableFrom(serverFromType))
|
||||
{
|
||||
this.Container.RegisterTransient(serverFromType, serverToType);
|
||||
|
||||
@@ -23,37 +23,31 @@ namespace TouchSocket.Rpc
|
||||
/// <summary>
|
||||
/// 生成扩展同步代码
|
||||
/// </summary>
|
||||
ExtensionSync =1,
|
||||
ExtensionSync = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 生成扩展异步代码
|
||||
/// </summary>
|
||||
ExtensionAsync = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 包含扩展(源代码生成无效)
|
||||
/// </summary>
|
||||
[Obsolete("该值已被弃用,请使用颗粒度更小的配置", true)]
|
||||
IncludeExtension = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 生成实例类同步代码(源代码生成无效)
|
||||
/// </summary>
|
||||
InstanceSync = 8,
|
||||
InstanceSync = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 生成实例类异步代码(源代码生成无效)
|
||||
/// </summary>
|
||||
InstanceAsync = 16,
|
||||
InstanceAsync = 8,
|
||||
|
||||
/// <summary>
|
||||
/// 生成接口同步代码
|
||||
/// </summary>
|
||||
InterfaceSync = 32,
|
||||
InterfaceSync = 16,
|
||||
|
||||
/// <summary>
|
||||
/// 生成接口异步代码
|
||||
/// </summary>
|
||||
InterfaceAsync = 64,
|
||||
InterfaceAsync = 32
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace TouchSocket.Rpc
|
||||
/// 函数标识
|
||||
/// </summary>
|
||||
[Flags]
|
||||
[Obsolete("此枚举值已被弃用,当第一个参数是ICallContext时,自动识别。",true)]
|
||||
[Obsolete("此枚举值已被弃用,当第一个参数是ICallContext时,自动识别。", true)]
|
||||
public enum MethodFlags
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace TouchSocket.Rpc
|
||||
{
|
||||
return (T)await client.InvokeAsync(typeof(T), invokeKey, invokeOption, parameters);
|
||||
}
|
||||
|
||||
#endregion RpcClient
|
||||
|
||||
#region ITargetRpcClient
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endif
|
||||
@@ -26,6 +26,7 @@ namespace TouchSocket.Rpc
|
||||
public static class RpcStoreExtension
|
||||
{
|
||||
#if !NET6_0_OR_GREATER
|
||||
|
||||
/// <summary>
|
||||
/// 注册所有服务
|
||||
/// </summary>
|
||||
@@ -52,8 +53,8 @@ namespace TouchSocket.Rpc
|
||||
}
|
||||
return types.Count;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 注册服务
|
||||
@@ -63,6 +64,7 @@ namespace TouchSocket.Rpc
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void RegisterServer<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(this RpcStore rpcStore) where T : IRpcServer
|
||||
#else
|
||||
|
||||
public static void RegisterServer<T>(this RpcStore rpcStore) where T : IRpcServer
|
||||
#endif
|
||||
|
||||
@@ -79,6 +81,7 @@ namespace TouchSocket.Rpc
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void RegisterServer(this RpcStore rpcStore, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type providerType)
|
||||
#else
|
||||
|
||||
public static void RegisterServer(this RpcStore rpcStore, Type providerType)
|
||||
#endif
|
||||
{
|
||||
@@ -94,6 +97,7 @@ namespace TouchSocket.Rpc
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void RegisterServer<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TFrom, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TTo>(this RpcStore rpcStore) where TFrom : class, IRpcServer where TTo : TFrom
|
||||
#else
|
||||
|
||||
public static void RegisterServer<TFrom, TTo>(this RpcStore rpcStore) where TFrom : class, IRpcServer where TTo : TFrom
|
||||
#endif
|
||||
|
||||
@@ -109,6 +113,7 @@ namespace TouchSocket.Rpc
|
||||
#if NET6_0_OR_GREATER
|
||||
public static void RegisterServer<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TFrom>(this RpcStore rpcStore, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TFrom rpcServer) where TFrom : class, IRpcServer
|
||||
#else
|
||||
|
||||
public static void RegisterServer<TFrom>(this RpcStore rpcStore, TFrom rpcServer) where TFrom : class, IRpcServer
|
||||
#endif
|
||||
|
||||
|
||||
11
src/TouchSocket.SourceGenerator/AnalyzerReleases.Shipped.md
Normal file
11
src/TouchSocket.SourceGenerator/AnalyzerReleases.Shipped.md
Normal file
@@ -0,0 +1,11 @@
|
||||
; Shipped analyzer releases
|
||||
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
|
||||
|
||||
## Release 1.0
|
||||
|
||||
### New Rules
|
||||
|
||||
Rule ID | Category | Severity | Notes
|
||||
--------|----------|----------|--------------------
|
||||
Rpc0001 | Rpc | Warning | Rpc0001_AnalyzerName
|
||||
Rpc0002 | Rpc | Error | Rpc0002_AnalyzerName
|
||||
@@ -0,0 +1,2 @@
|
||||
; Unshipped analyzer release
|
||||
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TouchSocket
|
||||
@@ -13,10 +12,9 @@ namespace TouchSocket
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (typeSymbol.BaseType != null)
|
||||
{
|
||||
var b= IsInheritFrom(typeSymbol.BaseType, baseType);
|
||||
var b = IsInheritFrom(typeSymbol.BaseType, baseType);
|
||||
if (b)
|
||||
{
|
||||
return true;
|
||||
@@ -50,7 +48,6 @@ namespace TouchSocket
|
||||
return new string(name);
|
||||
}
|
||||
|
||||
|
||||
public static bool HasAttribute(this ISymbol symbol, INamedTypeSymbol attribute)
|
||||
{
|
||||
foreach (var attr in symbol.GetAttributes())
|
||||
@@ -84,7 +81,6 @@ namespace TouchSocket
|
||||
return (value & flag) == flag;
|
||||
}
|
||||
|
||||
|
||||
public static bool HasReturn(this IMethodSymbol method)
|
||||
{
|
||||
if (method.ReturnsVoid || method.ReturnType.ToDisplayString() == typeof(Task).FullName)
|
||||
@@ -93,6 +89,5 @@ namespace TouchSocket
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user