当前位置: 首页>>代码示例>>C#>>正文


C# IService.ThrowIfNull方法代码示例

本文整理汇总了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;
        }
开发者ID:JANCARLO123,项目名称:google-apis,代码行数:32,代码来源:GoogleSchemaGenerator.cs

示例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;
        }
开发者ID:jithuin,项目名称:infogeezer,代码行数:24,代码来源:ImplementationDetailsGenerator.cs

示例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;
        }
开发者ID:nick0816,项目名称:LoggenCSG,代码行数:26,代码来源:GoogleServiceGenerator.cs

示例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;
 }
开发者ID:JANCARLO123,项目名称:google-apis,代码行数:9,代码来源:GoogleApiException.cs

示例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;
        }
开发者ID:jithuin,项目名称:infogeezer,代码行数:30,代码来源:ImplementationDetailsGenerator.cs


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