本文整理汇总了C#中ClientOptions类的典型用法代码示例。如果您正苦于以下问题:C# ClientOptions类的具体用法?C# ClientOptions怎么用?C# ClientOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientOptions类属于命名空间,在下文中一共展示了ClientOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例8: CheckUnusedWorkingDirectory
protected override bool CheckUnusedWorkingDirectory(ClientOptions options)
{
return true;
}
示例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);
}
}
示例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;
}
示例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(
//.........这里部分代码省略.........
示例12: Execute
public override int Execute(ClientController controller, ClientOptions options)
{
controller.CopyFromVM(options.Values[1], options.Values[2],
options.Recursive, options.Force);
return 0;
}
示例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;
}
示例14: CheckUnusedRecursive
protected override bool CheckUnusedRecursive(ClientOptions options)
{
return true;
}
示例15: CheckUnusedForce
protected override bool CheckUnusedForce(ClientOptions options)
{
return true;
}