當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。