• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ClientOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ClientOptions的典型用法代码示例。如果您正苦于以下问题:C# ClientOptions类的具体用法?C# ClientOptions怎么用?C# ClientOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClientOptions类属于命名空间,在下文中一共展示了ClientOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: StressTestClient

 private StressTestClient(ClientOptions options, List<string> serverAddresses, Dictionary<string, int> weightedTestCases)
 {
     this.options = options;
     this.serverAddresses = serverAddresses;
     this.weightedTestCases = weightedTestCases;
     this.testCaseGenerator = new WeightedRandomGenerator(this.weightedTestCases);
 }
开发者ID:nerdrew,项目名称:grpc,代码行数:7,代码来源:StressTestClient.cs


示例2: WebApiClientSettings

 public WebApiClientSettings(string serviceUrl, ClientOptions options = ClientOptions.Default, 
     IContentSerializer serializer = null, IClientErrorHandler errorHandler = null, Type badRequestContentType = null, Type serverErrorContentType = null)
 {
     Util.Check(!string.IsNullOrWhiteSpace(serviceUrl), "ServiceUrl may not be empty.");
       if (serviceUrl.EndsWith("/"))
     serviceUrl = serviceUrl.Substring(0, serviceUrl.Length - 1);
       ServiceUrl = serviceUrl;
       Options = options;
       Serializer = serializer ?? new JsonContentSerializer(options);
       ErrorHandler = errorHandler ?? new DefaultClientErrorHandler(Serializer, badRequestContentType, serverErrorContentType);
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:11,代码来源:WebApiClientSettings.cs


示例3: JsonContentSerializer

 public JsonContentSerializer(ClientOptions clientOptions, JsonSerializerSettings settings = null) {
   if (settings == null) {
     settings = new JsonSerializerSettings();
     settings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); //serialize enum as names, not numbers
     settings.ContractResolver = new NodeNameContractResolver(clientOptions); //to process NodeAttribute attribute
   }
   _jsonSerializerSettings = settings;
   _serializer = JsonSerializer.Create(_jsonSerializerSettings);
   SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
   SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));
   _mediaTypes.Add(JsonMediaType);
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:12,代码来源:JsonContentSerializer.cs


示例4: Configuration

 internal Configuration(Policies policies,
                      ProtocolOptions protocolOptions,
                      PoolingOptions poolingOptions,
                      SocketOptions socketOptions,
                      ClientOptions clientOptions,
                      IAuthInfoProvider authProvider)
 {
     this._policies = policies;
     this._protocolOptions = protocolOptions;
     this._poolingOptions = poolingOptions;
     this._socketOptions = socketOptions;
     this._clientOptions = clientOptions;
     this._authProvider = authProvider;
 }
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:14,代码来源:Configuration.cs


示例5: Configuration

 public Configuration(Policies policies,
                      ProtocolOptions protocolOptions,
                      PoolingOptions poolingOptions,
                      SocketOptions socketOptions,
                      ClientOptions clientOptions,
                      IAuthInfoProvider authProvider,
                      bool metricsEnabled)
 {
     this._policies = policies;
     this._protocolOptions = protocolOptions;
     this._poolingOptions = poolingOptions;
     this._socketOptions = socketOptions;
     this._clientOptions = clientOptions;
     this._authProvider = authProvider;
     this._metricsEnabled = metricsEnabled;
 }
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:16,代码来源:Configuration.cs


示例6: Configuration

 internal Configuration(Policies policies,
                        ProtocolOptions protocolOptions,
                        PoolingOptions poolingOptions,
                        SocketOptions socketOptions,
                        ClientOptions clientOptions,
                        IAuthProvider authProvider,
                        IAuthInfoProvider authInfoProvider,
                        QueryOptions queryOptions)
 {
     _policies = policies;
     _protocolOptions = protocolOptions;
     _poolingOptions = poolingOptions;
     _socketOptions = socketOptions;
     _clientOptions = clientOptions;
     _authProvider = authProvider;
     _authInfoProvider = authInfoProvider;
     _queryOptions = queryOptions;
 }
开发者ID:rasmus-s,项目名称:csharp-driver,代码行数:18,代码来源:Configuration.cs


示例7: Run

        public static void Run(string[] args)
        {
            var options = new ClientOptions();
            if (!Parser.Default.ParseArguments(args, options))
            {
                Environment.Exit(1);
            }

            var interopClient = new InteropClient(options);
            interopClient.Run().Wait();
        }
开发者ID:endlessm,项目名称:chromium-browser,代码行数:11,代码来源:InteropClient.cs


示例8: CheckUnusedWorkingDirectory

 protected override bool CheckUnusedWorkingDirectory(ClientOptions options)
 {
     return true;
 }
开发者ID:timonela,项目名称:mb-unit,代码行数:4,代码来源:ClientProgram.cs


示例9: RunTestCaseAsync

 private async Task RunTestCaseAsync(TestService.TestServiceClient client, ClientOptions options)
 {
     switch (options.TestCase)
     {
         case "empty_unary":
             RunEmptyUnary(client);
             break;
         case "large_unary":
             RunLargeUnary(client);
             break;
         case "client_streaming":
             await RunClientStreamingAsync(client);
             break;
         case "server_streaming":
             await RunServerStreamingAsync(client);
             break;
         case "ping_pong":
             await RunPingPongAsync(client);
             break;
         case "empty_stream":
             await RunEmptyStreamAsync(client);
             break;
         case "compute_engine_creds":
             RunComputeEngineCreds(client, options.DefaultServiceAccount, options.OAuthScope);
             break;
         case "jwt_token_creds":
             RunJwtTokenCreds(client, options.DefaultServiceAccount);
             break;
         case "oauth2_auth_token":
             await RunOAuth2AuthTokenAsync(client, options.DefaultServiceAccount, options.OAuthScope);
             break;
         case "per_rpc_creds":
             await RunPerRpcCredsAsync(client, options.DefaultServiceAccount, options.OAuthScope);
             break;
         case "cancel_after_begin":
             await RunCancelAfterBeginAsync(client);
             break;
         case "cancel_after_first_response":
             await RunCancelAfterFirstResponseAsync(client);
             break;
         case "timeout_on_sleeping_server":
             await RunTimeoutOnSleepingServerAsync(client);
             break;
         case "benchmark_empty_unary":
             RunBenchmarkEmptyUnary(client);
             break;
         default:
             throw new ArgumentException("Unknown test case " + options.TestCase);
     }
 }
开发者ID:nkibler,项目名称:grpc,代码行数:50,代码来源:InteropClient.cs


示例10: CreateXmlSerializerImportOptions

        /// <summary>
        /// Create appropriate XmlSerializerImportOptions for the generator
        /// </summary>
        /// <param name="proxyOptions">Options for the code/config generation</param>
        /// <param name="targetCompileUnit">Compile unit we are going to generate the client code in</param>
        /// <param name="codeDomProvider">CodeDom provider for the language we are using</param>
        /// <param name="proxyNamespace">CLR namespace we'll put the client code in</param>
        /// <returns></returns>
        protected static XmlSerializerImportOptions CreateXmlSerializerImportOptions(
                                ClientOptions proxyOptions,
                                CodeCompileUnit targetCompileUnit,
                                System.CodeDom.Compiler.CodeDomProvider codeDomProvider,
                                string proxyNamespace,
                                System.Type typedDataSetSchemaImporterExtension)
        {
            System.ServiceModel.Channels.XmlSerializerImportOptions xmlSerializerOptions = new XmlSerializerImportOptions(targetCompileUnit);
            System.Web.Services.Description.WebReferenceOptions webReferenceOptions = new System.Web.Services.Description.WebReferenceOptions();

            webReferenceOptions.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties | System.Xml.Serialization.CodeGenerationOptions.GenerateOrder;

            if (proxyOptions.EnableDataBinding)
            {
                webReferenceOptions.CodeGenerationOptions |= System.Xml.Serialization.CodeGenerationOptions.EnableDataBinding;
            }

            webReferenceOptions.SchemaImporterExtensions.Add(typedDataSetSchemaImporterExtension.AssemblyQualifiedName);
            webReferenceOptions.SchemaImporterExtensions.Add(typeof(System.Data.DataSetSchemaImporterExtension).AssemblyQualifiedName);

            /* 

















*/

            xmlSerializerOptions.WebReferenceOptions = webReferenceOptions;
            xmlSerializerOptions.CodeProvider = codeDomProvider;

            xmlSerializerOptions.ClrNamespace = proxyNamespace;

            return xmlSerializerOptions;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:55,代码来源:VSWCFServiceContractGenerator.cs


示例11: LoadSharedDataContractTypes

        protected static IEnumerable<Type> LoadSharedDataContractTypes(
                ClientOptions proxyOptions, IContractGeneratorReferenceTypeLoader typeLoader, int targetFrameworkVersion, IList<ProxyGenerationError> importErrors)
        {
            if (typeLoader == null) throw new ArgumentNullException("typeLoader");

            // the value in sharedTypeTable is why we add this type in the shared type list. 
            // if it is only added because it is in the referenced assembly, the value will be null, otherwise it contains the entry in the type inclusion list
            // if the type is also in the exclusion list, we will report an error if the type is comming from the inclusion list, but no error if it comes from a referenced assembly only.
            Dictionary<Type, ReferencedType> sharedTypeTable = new Dictionary<Type, ReferencedType>();

            // load all types in referencedAssemblies
            IEnumerable<Assembly> referencedAssemblies = LoadReferenedAssemblies(proxyOptions, typeLoader, importErrors);
            if (referencedAssemblies != null)
            {
                foreach (Assembly referencedAssembly in referencedAssemblies)
                {
                    var typeLoader2 = typeLoader as IContractGeneratorReferenceTypeLoader2;
                    if (typeLoader2 != null)
                    {
                        foreach (Type sharedType in typeLoader2.LoadExportedTypes(referencedAssembly))
                        {
                            sharedTypeTable.Add(sharedType, null);
                        }
                    }
                    else
                    {
                        // Fall back to the original approach using IContractGeneratorReferenceTypeLoader.LoadType().
                        foreach (Type typeInAssembly in referencedAssembly.GetExportedTypes())
                        {
                            try
                            {
                                // Do multi-targeting check by calling IContractGeneratorReferenceTypeLoader.LoadType().                            
                                if (typeLoader.LoadType(typeInAssembly.FullName) != null)
                                {
                                    sharedTypeTable.Add(typeInAssembly, null);
                                }
                            }
                            catch (NotSupportedException)
                            {
                                // NotSupportedException is thrown by multi-targeting check. It's normal if some types not existing in the current FX.
                                // So we can safely ---- it.
                            }
                            catch (Exception ex)
                            {
                                // fail to load one type in an assembly: warning message
                                importErrors.Add(
                                    new ProxyGenerationError(
                                        ProxyGenerationError.GeneratorState.GenerateCode,
                                        String.Empty,
                                        ex,
                                        true));
                            }
                        }
                    }
                }
            }

            // load types in DataContractTypeList
            foreach (ReferencedType referencedType in proxyOptions.ReferencedDataContractTypeList)
            {
                try
                {
                    Type sharedType = typeLoader.LoadType(referencedType.TypeName);

                    // verify...
                    if (!IsTypeShareable(sharedType))
                    {
                        importErrors.Add(
                                new ProxyGenerationError(
                                    ProxyGenerationError.GeneratorState.GenerateCode,
                                    String.Empty,
                                    new FormatException(String.Format(CultureInfo.CurrentCulture, WCFModelStrings.ReferenceGroup_SharedTypeMustBePublic, referencedType.TypeName)))
                            );
                        continue;
                    }

                    sharedTypeTable[sharedType] = referencedType;
                }
                catch (Exception ex)
                {
                    importErrors.Add(new ProxyGenerationError(
                                    ProxyGenerationError.GeneratorState.GenerateCode,
                                    String.Empty,
                                    ex));
                }
            }

            // remove excluded types
            foreach (ReferencedType excludedType in proxyOptions.ExcludedTypeList)
            {
                try
                {
                    Type sharedType = typeLoader.LoadType(excludedType.TypeName);

                    if (sharedTypeTable.ContainsKey(sharedType))
                    {
                        if (sharedTypeTable[sharedType] != null)
                        {
                            // error message
                            importErrors.Add(new ProxyGenerationError(
//.........这里部分代码省略.........
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:VSWCFServiceContractGenerator.cs


示例12: Execute

 public override int Execute(ClientController controller, ClientOptions options)
 {
     controller.CopyFromVM(options.Values[1], options.Values[2],
         options.Recursive, options.Force);
     return 0;
 }
开发者ID:timonela,项目名称:mb-unit,代码行数:6,代码来源:ClientProgram.cs


示例13: LoadSharedCollectionTypes

        /// <summary>
        /// Load the list of types that we have specified as collection types in our client options.
        /// The collection types will be used to generate collections in the data contracts.
        /// </summary>
        /// <param name="proxyOptions">Options specifying the list of collection types</param>
        /// <param name="typeLoader">Type loader that resolves type names to actual CLR types</param>
        /// <param name="importErrors">Errors encountered while loading the collection types</param>
        /// <return></return>
        /// <remarks></remarks>
        protected static IEnumerable<Type> LoadSharedCollectionTypes(ClientOptions proxyOptions, IContractGeneratorReferenceTypeLoader typeLoader, IList<ProxyGenerationError> importErrors)
        {
            List<Type> referencedCollectionTypes = new List<Type>();
            foreach (ReferencedCollectionType referencedCollectionMapping in proxyOptions.CollectionMappingList)
            {
                try
                {
                    Type collectionType = typeLoader.LoadType(referencedCollectionMapping.TypeName);

                    // verify...
                    if (!IsTypeShareable(collectionType))
                    {
                        importErrors.Add(
                                new ProxyGenerationError(
                                    ProxyGenerationError.GeneratorState.GenerateCode,
                                    String.Empty,
                                    new FormatException(String.Format(CultureInfo.CurrentCulture, WCFModelStrings.ReferenceGroup_SharedTypeMustBePublic, referencedCollectionMapping.TypeName)))
                            );
                        continue;
                    }

                    referencedCollectionTypes.Add(collectionType);
                }
                catch (Exception ex)
                {
                    importErrors.Add(new ProxyGenerationError(
                                    ProxyGenerationError.GeneratorState.GenerateCode,
                                    String.Empty,
                                    ex));
                }
            }
            return referencedCollectionTypes;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:42,代码来源:VSWCFServiceContractGenerator.cs


示例14: CheckUnusedRecursive

 protected override bool CheckUnusedRecursive(ClientOptions options)
 {
     return true;
 }
开发者ID:timonela,项目名称:mb-unit,代码行数:4,代码来源:ClientProgram.cs


示例15: CheckUnusedForce

 protected override bool CheckUnusedForce(ClientOptions options)
 {
     return true;
 }
开发者ID:timonela,项目名称:mb-unit,代码行数:4,代码来源:ClientProgram.cs


示例16: CheckValues

 protected override bool CheckValues(ClientOptions options)
 {
     return Check(options.Values.Count >= 3, "Missing files to copy.")
         && Check(options.Values.Count == 3, "Found excess arguments.");
 }
开发者ID:timonela,项目名称:mb-unit,代码行数:5,代码来源:ClientProgram.cs


示例17: CheckUnusedTimeout

 protected override bool CheckUnusedTimeout(ClientOptions options)
 {
     return true;
 }
开发者ID:timonela,项目名称:mb-unit,代码行数:4,代码来源:ClientProgram.cs


示例18: RunTestCaseAsync

 private async Task RunTestCaseAsync(Channel channel, ClientOptions options)
 {
     var client = new TestService.TestServiceClient(channel);
     switch (options.TestCase)
     {
         case "empty_unary":
             RunEmptyUnary(client);
             break;
         case "large_unary":
             RunLargeUnary(client);
             break;
         case "client_streaming":
             await RunClientStreamingAsync(client);
             break;
         case "server_streaming":
             await RunServerStreamingAsync(client);
             break;
         case "ping_pong":
             await RunPingPongAsync(client);
             break;
         case "empty_stream":
             await RunEmptyStreamAsync(client);
             break;
         case "compute_engine_creds":
             RunComputeEngineCreds(client, options.DefaultServiceAccount, options.OAuthScope);
             break;
         case "jwt_token_creds":
             RunJwtTokenCreds(client);
             break;
         case "oauth2_auth_token":
             await RunOAuth2AuthTokenAsync(client, options.OAuthScope);
             break;
         case "per_rpc_creds":
             await RunPerRpcCredsAsync(client, options.OAuthScope);
             break;
         case "cancel_after_begin":
             await RunCancelAfterBeginAsync(client);
             break;
         case "cancel_after_first_response":
             await RunCancelAfterFirstResponseAsync(client);
             break;
         case "timeout_on_sleeping_server":
             await RunTimeoutOnSleepingServerAsync(client);
             break;
         case "custom_metadata":
             await RunCustomMetadataAsync(client);
             break;
         case "status_code_and_message":
             await RunStatusCodeAndMessageAsync(client);
             break;
         case "unimplemented_method":
             RunUnimplementedMethod(new UnimplementedService.UnimplementedServiceClient(channel));
             break;
         case "client_compressed_unary":
             RunClientCompressedUnary(client);
             break;
         case "client_compressed_streaming":
             await RunClientCompressedStreamingAsync(client);
             break;
         default:
             throw new ArgumentException("Unknown test case " + options.TestCase);
     }
 }
开发者ID:wuyunhao,项目名称:grpc,代码行数:63,代码来源:InteropClient.cs


示例19: Run

        public static void Run(string[] args)
        {
            var options = new ClientOptions();
            if (!Parser.Default.ParseArguments(args, options))
            {
                Environment.Exit(1);
            }

            GrpcPreconditions.CheckArgument(options.NumChannelsPerServer > 0);
            GrpcPreconditions.CheckArgument(options.NumStubsPerChannel > 0);

            var serverAddresses = options.ServerAddresses.Split(',');
            GrpcPreconditions.CheckArgument(serverAddresses.Length > 0, "You need to provide at least one server address");

            var testCases = ParseWeightedTestCases(options.TestCases);
            GrpcPreconditions.CheckArgument(testCases.Count > 0, "You need to provide at least one test case");

            var interopClient = new StressTestClient(options, serverAddresses.ToList(), testCases);
            interopClient.Run().Wait();
        }
开发者ID:rwightman,项目名称:grpc,代码行数:20,代码来源:StressTestClient.cs


示例20: LoadReferenedAssemblies

        /// <summary>
        /// Load referenced assemblies
        /// </summary>
        /// <param name="proxyOptions"></param>
        /// <param name="typeLoader"></param>
        /// <param name="importErrors"></param>
        /// <return></return>
        /// <remarks></remarks>
        private static IEnumerable<Assembly> LoadReferenedAssemblies(ClientOptions proxyOptions, IContractGeneratorReferenceTypeLoader typeLoader, IList<ProxyGenerationError> importErrors)
        {
            List<Assembly> referencedAssemblies = new List<Assembly>();
            if (proxyOptions.ReferenceAllAssemblies)
            {
                try
                {
                    IEnumerable<Exception> loadingErrors = null;
                    IEnumerable<Assembly> allAssemblies = null;
                    typeLoader.LoadAllAssemblies(out allAssemblies, out loadingErrors);
                    if (loadingErrors != null)
                    {
                        // treat as warning messages
                        foreach (Exception ex in loadingErrors)
                        {
                            importErrors.Add(new ProxyGenerationError(
                                            ProxyGenerationError.GeneratorState.GenerateCode,
                                            String.Empty,
                                            ex,
                                            true));
                        }
                    }

                    if (allAssemblies != null)
                    {
                        referencedAssemblies.AddRange(allAssemblies);
                    }
                }
                catch (Exception ex)
                {
                    importErrors.Add(new ProxyGenerationError(
                                    ProxyGenerationError.GeneratorState.GenerateCode,
                                    String.Empty,
                                    ex));
                }
            }

            foreach (ReferencedAssembly referencedAssembly in proxyOptions.ReferencedAssemblyList)
            {
                try
                {
                    Assembly refAssembly = typeLoader.LoadAssembly(referencedAssembly.AssemblyName);
                    if (refAssembly != null && !referencedAssemblies.Contains(refAssembly))
                    {
                        referencedAssemblies.Add(refAssembly);
                    }
                }
                catch (Exception ex)
                {
                    importErrors.Add(new ProxyGenerationError(
                                    ProxyGenerationError.GeneratorState.GenerateCode,
                                    String.Empty,
                                    ex));
                }
            }
            return referencedAssemblies;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:65,代码来源:VSWCFServiceContractGenerator.cs



注:本文中的ClientOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ClientPacket类代码示例发布时间:2022-05-24
下一篇:
C# ClientMsgProtobuf类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap