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


C# Type.ThrowIfNull方法代码示例

本文整理汇总了C#中System.Type.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# Type.ThrowIfNull方法的具体用法?C# Type.ThrowIfNull怎么用?C# Type.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Type的用法示例。


在下文中一共展示了Type.ThrowIfNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MapAsync

		public Task<MapResult> MapAsync(HttpContextBase context, Type type, MethodInfo method, ParameterInfo parameter)
		{
			context.ThrowIfNull("request");
			type.ThrowIfNull("type");
			method.ThrowIfNull("method");
			parameter.ThrowIfNull("parameter");

			Type parameterType = parameter.ParameterType;
			var reader = new StreamReader(context.Request.InputStream, context.Request.ContentEncoding);
			string json = reader.ReadToEnd();
			object jsonModel;

			try
			{
				jsonModel = JsonConvert.DeserializeObject(json, parameterType, _serializerSettings);
			}
			catch (Exception exception)
			{
				if (_errorHandling == DataConversionErrorHandling.ThrowException)
				{
					throw new ApplicationException(String.Format("Request content could not be deserialized to '{0}'.", parameterType.FullName), exception);
				}
				jsonModel = parameterType.GetDefaultValue();
			}

			return MapResult.ValueMapped(jsonModel).AsCompletedTask();
		}
开发者ID:nathan-alden,项目名称:junior-route,代码行数:27,代码来源:JsonModelMapper.cs

示例2: CanMapTypeAsync

        public Task<bool> CanMapTypeAsync(HttpContextBase context, Type parameterType)
        {
            context.ThrowIfNull("context");
            parameterType.ThrowIfNull("parameterType");

            return (parameterType == typeof(HttpServerUtilityBase)).AsCompletedTask();
        }
开发者ID:nathan-alden,项目名称:junior-route,代码行数:7,代码来源:HttpServerUtilityBaseMapper.cs

示例3: CanMapType

        public bool CanMapType(HttpRequestBase request, Type parameterType)
        {
            request.ThrowIfNull("request");
            parameterType.ThrowIfNull("parameterType");

            return true;
        }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:7,代码来源:DefaultValueMapper.cs

示例4: CanMapTypeAsync

		public async Task<bool> CanMapTypeAsync(HttpContextBase context, Type parameterType)
		{
			context.ThrowIfNull("context");
			parameterType.ThrowIfNull("parameterType");

			return context.Request.ContentType == "application/json" && await Task.Run(() => _parameterTypeMatchDelegate(parameterType));
		}
开发者ID:nathan-alden,项目名称:junior-route,代码行数:7,代码来源:JsonModelMapper.cs

示例5: Map

        public IdResult Map(Type type, MethodInfo method)
        {
            type.ThrowIfNull("type");
            method.ThrowIfNull("method");

            return IdResult.IdMapped(_guidFactory.Random());
        }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:7,代码来源:RandomIdMapper.cs

示例6: MustAuthenticateAsync

        public Task<bool> MustAuthenticateAsync(Type type, MethodInfo method)
        {
            type.ThrowIfNull("type");
            method.ThrowIfNull("method");

            return method.GetCustomAttributes(typeof(AuthenticateAttribute), false).Any().AsCompletedTask();
        }
开发者ID:nathan-alden,项目名称:junior-route,代码行数:7,代码来源:AuthenticateAttributeStrategy.cs

示例7: MustAuthenticate

        public bool MustAuthenticate(Type type, MethodInfo method)
        {
            type.ThrowIfNull("type");
            method.ThrowIfNull("method");

            return method.GetCustomAttributes(typeof(AuthenticateAttribute), false).Any();
        }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:7,代码来源:AuthenticateAttributeStrategy.cs

示例8: CanMapTypeAsync

		public async Task<bool> CanMapTypeAsync(HttpContextBase context, Type parameterType)
		{
			context.ThrowIfNull("context");
			parameterType.ThrowIfNull("parameterType");

			return await Task.Run(() => _parameterTypeMatchDelegate(parameterType));
		}
开发者ID:nathan-alden,项目名称:junior-route,代码行数:7,代码来源:ModelMapper.cs

示例9: CanMapTypeAsync

        public override Task<bool> CanMapTypeAsync(HttpContextBase context, Type parameterType)
        {
            context.ThrowIfNull("context");
            parameterType.ThrowIfNull("parameterType");

            return parameterType.ImplementsInterface<IConvertible>().AsCompletedTask();
        }
开发者ID:nathan-alden,项目名称:junior-route,代码行数:7,代码来源:ConvertibleMapper.cs

示例10: IsNonGenericImplementationOf

        public static bool IsNonGenericImplementationOf(this Type type, Type interfaceType)
        {
            type.ThrowIfNull("type");
            interfaceType.ThrowIfNull("interfaceType");

            return type.GetInterfaces().Any(interfaceType.Equals);
        }
开发者ID:zacharyyates,项目名称:yak,代码行数:7,代码来源:TypeExtensions.cs

示例11: CanMapTypeAsync

        public Task<bool> CanMapTypeAsync(HttpContextBase context, Type parameterType)
        {
            context.ThrowIfNull("context");
            parameterType.ThrowIfNull("parameterType");

            return true.AsCompletedTask();
        }
开发者ID:nathan-alden,项目名称:junior-route,代码行数:7,代码来源:DefaultValueMapper.cs

示例12: CustomMapperAttribute

        public CustomMapperAttribute(Type customMapperType)
        {
            customMapperType.ThrowIfNull("customMapperType");

            if (customMapperType.IsNotPublic)
            {
                throw new ArgumentException("Type must be public.", "customMapperType");
            }
            if (customMapperType.IsAbstract)
            {
                throw new ArgumentException("Type cannot be abstract or static.", "customMapperType");
            }
            if (!customMapperType.ImplementsInterface<ICustomMapper>())
            {
                throw new ArgumentException(String.Format("Type must implement {0}.", customMapperType.FullName), "customMapperType");
            }

            ConstructorInfo constructorInfo = customMapperType.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null);

            if (constructorInfo == null)
            {
                throw new ArgumentException("Type must declare a public default constructor.", "customMapperType");
            }

            _mapper = (ICustomMapper)Activator.CreateInstance(customMapperType);
        }
开发者ID:nathan-alden,项目名称:junior-route,代码行数:26,代码来源:CustomMapperAttribute.cs

示例13: CanMapType

        public bool CanMapType(HttpRequestBase request, Type parameterType)
        {
            request.ThrowIfNull("request");
            parameterType.ThrowIfNull("parameterType");

            return parameterType.ImplementsInterface<IConvertible>();
        }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:7,代码来源:QueryStringToIConvertibleMapper.cs

示例14: AspNetDiagnosticConfiguration

		public AspNetDiagnosticConfiguration(
			Type cacheType,
			IEnumerable<Type> requestFilterTypes,
			IEnumerable<Type> responseGeneratorTypes,
			IEnumerable<Type> responseHandlerTypes,
			IEnumerable<Type> errorHandlerTypes,
			Type antiCsrfCookieManagerType = null,
			Type antiCsrfNonceValidatorType = null,
			Type antiCsrfResponseGeneratorType = null)
		{
			cacheType.ThrowIfNull("cacheType");
			requestFilterTypes.ThrowIfNull("requestFilterTypes");
			responseGeneratorTypes.ThrowIfNull("responseGeneratorTypes");
			responseHandlerTypes.ThrowIfNull("responseHandlerTypes");
			errorHandlerTypes.ThrowIfNull("errorHandlerTypes");

			_cacheType = cacheType;
			_requestFilterTypes = requestFilterTypes.ToArray();
			_responseGeneratorTypes = responseGeneratorTypes.ToArray();
			_responseHandlerTypes = responseHandlerTypes.ToArray();
			_errorHandlerTypes = errorHandlerTypes.ToArray();
			_antiCsrfCookieManagerType = antiCsrfCookieManagerType;
			_antiCsrfNonceValidatorType = antiCsrfNonceValidatorType;
			_antiCsrfResponseGeneratorType = antiCsrfResponseGeneratorType;
		}
开发者ID:kelong,项目名称:JuniorRoute,代码行数:25,代码来源:AspNetDiagnosticConfiguration.cs

示例15: Populate

		public void Populate(
			Type cacheType,
			IEnumerable<Type> requestFilterTypes,
			IEnumerable<Type> responseGeneratorTypes,
			IEnumerable<Type> responseHandlerTypes,
			IEnumerable<Type> errorHandlerTypes,
			Type antiCsrfCookieManagerType,
			Type antiCsrfNonceValidatorType,
			Type antiCsrfResponseGeneratorType)
		{
			cacheType.ThrowIfNull("cacheType");
			requestFilterTypes.ThrowIfNull("requestFilterTypes");
			responseGeneratorTypes.ThrowIfNull("responseGeneratorTypes");
			responseHandlerTypes.ThrowIfNull("responseHandlerTypes");
			errorHandlerTypes.ThrowIfNull("errorHandlerTypes");

			CacheType = cacheType;
			RequestFilterTypes = requestFilterTypes;
			ResponseGeneratorTypes = responseGeneratorTypes;
			ResponseHandlerTypes = responseHandlerTypes;
			ErrorHandlerTypes = errorHandlerTypes;
			AntiCsrfCookieManagerType = antiCsrfCookieManagerType;
			AntiCsrfNonceValidatorType = antiCsrfNonceValidatorType;
			AntiCsrfResponseGeneratorType = antiCsrfResponseGeneratorType;
		}
开发者ID:kelong,项目名称:JuniorRoute,代码行数:25,代码来源:AspNetView.cs


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