diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/GrpcChannelProvider.cs b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/GrpcChannelProvider.cs index 1a708b8d6..45d36211c 100644 --- a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/GrpcChannelProvider.cs +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Unity/GrpcChannelProvider.cs @@ -40,17 +40,17 @@ public static GrpcChannelx CreateChannel(this IGrpcChannelProvider provider, Grp /// public static class GrpcChannelProvider { - private static IGrpcChannelProvider _defaultProvider; + static IGrpcChannelProvider defaultProvider; /// /// Gets a default channel provider. the provider will be initialized by . /// public static IGrpcChannelProvider Default - => _defaultProvider ?? throw new InvalidOperationException("The default GrpcChannelProvider is not configured yet. Setup GrpcChannelProviderHost or initialize manually. "); + => defaultProvider ?? throw new InvalidOperationException("The default GrpcChannelProvider is not configured yet. Setup GrpcChannelProviderHost or initialize manually. "); public static void SetDefaultProvider(IGrpcChannelProvider provider) { - _defaultProvider = provider; + defaultProvider = provider; } } @@ -59,34 +59,34 @@ public static void SetDefaultProvider(IGrpcChannelProvider provider) /// public sealed class LoggingGrpcChannelProvider : IGrpcChannelProvider { - private readonly IGrpcChannelProvider _baseProvider; + readonly IGrpcChannelProvider baseProvider; public LoggingGrpcChannelProvider(IGrpcChannelProvider baseProvider) { - _baseProvider = baseProvider ?? throw new ArgumentNullException(nameof(baseProvider)); + this.baseProvider = baseProvider ?? throw new ArgumentNullException(nameof(baseProvider)); } public GrpcChannelx CreateChannel(CreateGrpcChannelContext context) { - var channel = _baseProvider.CreateChannel(context); + var channel = baseProvider.CreateChannel(context); Debug.Log($"Channel Created: {context.Target.Host}:{context.Target.Port} ({(context.Target.IsInsecure ? "Insecure" : "Secure")}) [{channel.Id}]"); return channel; } public IReadOnlyCollection GetAllChannels() { - return _baseProvider.GetAllChannels(); + return baseProvider.GetAllChannels(); } public void UnregisterChannel(GrpcChannelx channel) { - _baseProvider.UnregisterChannel(channel); + baseProvider.UnregisterChannel(channel); Debug.Log($"Channel Unregistered: {channel.TargetUri.Host}:{channel.TargetUri.Port} [{channel.Id}]"); } public void ShutdownAllChannels() { - _baseProvider.ShutdownAllChannels(); + baseProvider.ShutdownAllChannels(); } } @@ -186,7 +186,7 @@ public DefaultGrpcChannelProvider(GrpcCCoreChannelOptions channelOptions) : base /// public class GrpcNetClientGrpcChannelProvider : GrpcChannelProviderBase { - readonly Func _defaultChannelOptionsFactory; + readonly Func defaultChannelOptionsFactory; public GrpcNetClientGrpcChannelProvider() : this(new GrpcChannelOptions()) { @@ -199,7 +199,7 @@ public GrpcNetClientGrpcChannelProvider(GrpcChannelOptions options) public GrpcNetClientGrpcChannelProvider(Func optionsFactory) { - _defaultChannelOptionsFactory = optionsFactory ?? throw new ArgumentNullException(nameof(optionsFactory)); + defaultChannelOptionsFactory = optionsFactory ?? throw new ArgumentNullException(nameof(optionsFactory)); } /// @@ -208,7 +208,7 @@ public GrpcNetClientGrpcChannelProvider(Func optionsFactory) protected override GrpcChannelx CreateChannelCore(int id, CreateGrpcChannelContext context) { var address = new Uri((context.Target.IsInsecure ? "http" : "https") + $"://{context.Target.Host}:{context.Target.Port}"); - var channelOptions = context.ChannelOptions.Get() ?? _defaultChannelOptionsFactory(); + var channelOptions = context.ChannelOptions.Get() ?? defaultChannelOptionsFactory(); var channel = GrpcChannel.ForAddress(address, channelOptions); var channelHolder = new GrpcChannelx( id, @@ -229,7 +229,7 @@ protected override GrpcChannelx CreateChannelCore(int id, CreateGrpcChannelConte /// public class GrpcCCoreGrpcChannelProvider : GrpcChannelProviderBase { - private readonly GrpcCCoreChannelOptions _defaultChannelOptions; + private readonly GrpcCCoreChannelOptions defaultChannelOptions; public GrpcCCoreGrpcChannelProvider() : this(new GrpcCCoreChannelOptions()) @@ -243,7 +243,7 @@ public GrpcCCoreGrpcChannelProvider(IReadOnlyList channelOptions) public GrpcCCoreGrpcChannelProvider(GrpcCCoreChannelOptions channelOptions) { - _defaultChannelOptions = channelOptions ?? throw new ArgumentNullException(nameof(channelOptions)); + defaultChannelOptions = channelOptions ?? throw new ArgumentNullException(nameof(channelOptions)); } /// @@ -251,7 +251,7 @@ public GrpcCCoreGrpcChannelProvider(GrpcCCoreChannelOptions channelOptions) /// protected override GrpcChannelx CreateChannelCore(int id, CreateGrpcChannelContext context) { - var channelOptions = context.ChannelOptions.Get() ?? _defaultChannelOptions; + var channelOptions = context.ChannelOptions.Get() ?? defaultChannelOptions; var channel = new Channel(context.Target.Host, context.Target.Port, context.Target.IsInsecure ? ChannelCredentials.Insecure : channelOptions.ChannelCredentials, channelOptions.ChannelOptions); var channelHolder = new GrpcChannelx( id,