本文整理汇总了C#中IService.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# IService.ThrowIfNull方法的具体用法?C# IService.ThrowIfNull怎么用?C# IService.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IService
的用法示例。
在下文中一共展示了IService.ThrowIfNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateSchemaClasses
/// <summary>
/// Generates all schema classes for the specified service
/// </summary>
/// <param name="service"></param>
/// <returns></returns>
public CodeNamespace GenerateSchemaClasses(IService service)
{
service.ThrowIfNull("service");
logger.Debug("Starting to generate schemas for {1} in namespace {0}", schemaNamespace, service.Name);
LogDecorators();
var codeNamespace = new CodeNamespace(schemaNamespace);
codeNamespace.Imports.Add(new CodeNamespaceImport("System"));
codeNamespace.Imports.Add(new CodeNamespaceImport("System.Collections"));
codeNamespace.Imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
SchemaGenerator generator = new SchemaGenerator(decorators);
// Generate implementation details
IDictionary<JsonSchema, SchemaImplementationDetails> implementationDetails =
implementationDetailsGenerator.GenerateDetails(service);
// Generate schemas
foreach (var schemaPair in service.Schemas)
{
logger.Debug("Generating Schema {0}", schemaPair.Key);
// Create schema
codeNamespace.Types.Add(
generator.CreateClass(schemaPair.Value, implementationDetails, service.Schemas.Keys));
}
return codeNamespace;
}
示例2: GenerateDetails
/// <summary>
/// Generates the implementation details for a whole service.
/// </summary>
public IDictionary<JsonSchema, SchemaImplementationDetails> GenerateDetails(IService service)
{
service.ThrowIfNull("service");
Dictionary<JsonSchema, SchemaImplementationDetails> dictionary =
new Dictionary<JsonSchema, SchemaImplementationDetails>();
// Traverse through all schemas and check if they require implementation details.
foreach (ISchema schema in service.Schemas.Values)
{
if (schema.SchemaDetails != null)
{
AddDetails(dictionary, schema.SchemaDetails);
}
}
// Create additional details for all schemas where they are necessary.
AddIsMethodResult(dictionary, service, service.Resources.Values);
return dictionary;
}
示例3: GoogleServiceGenerator
/// <summary>
/// Generates a new instance of the service generator for a specific service
/// </summary>
public GoogleServiceGenerator(IService service,
string clientNamespace,
IEnumerable<IResourceDecorator> resourceDecorators,
IEnumerable<IServiceDecorator> serviceDecorators,
IEnumerable<IResourceContainerDecorator> resourceContainerDecorators,
GoogleSchemaGenerator schemaGenerator)
{
service.ThrowIfNull("service");
clientNamespace.ThrowIfNull("clientNamespace");
resourceDecorators.ThrowIfNull("resourceDecorators");
serviceDecorators.ThrowIfNull("serviceDecorators");
resourceContainerDecorators.ThrowIfNull("resourceContainerDecorators");
codeClientNamespace = clientNamespace;
this.service = service;
// Defensive copy and readonly
this.resourceDecorators = new List<IResourceDecorator>(resourceDecorators).AsReadOnly();
this.serviceDecorators = new List<IServiceDecorator>(serviceDecorators).AsReadOnly();
this.resourceContainerDecorators =
new List<IResourceContainerDecorator>(resourceContainerDecorators).AsReadOnly();
this.schemaGenerator = schemaGenerator;
}
示例4: GoogleApiException
/// <summary>
/// Creates an API Service exception.
/// </summary>
public GoogleApiException(IService service, string message, Exception inner)
: base(message, inner)
{
service.ThrowIfNull("service");
this.service = service;
}
示例5: AddIsMethodResult
internal static void AddIsMethodResult(IDictionary<JsonSchema, SchemaImplementationDetails> details,
IService service,
IMethod method)
{
details.ThrowIfNull("details");
service.ThrowIfNull("service");
method.ThrowIfNull("method");
string id = method.ResponseType;
if (string.IsNullOrEmpty(id))
{
// Return if this method has no response type
return;
}
// Check if this name is a valid schema
if (!service.Schemas.ContainsKey(id))
{
return;
}
ISchema schema = service.Schemas[id];
// If no implementation details have been added yet, create a new entry
SchemaImplementationDetails implementationDetails = GetOrCreateDetails(details, schema.SchemaDetails);
// Change the value
implementationDetails.IsMethodResult = true;
}