本文整理汇总了C#中IEnumerable.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.ThrowIfNull方法的具体用法?C# IEnumerable.ThrowIfNull怎么用?C# IEnumerable.ThrowIfNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.ThrowIfNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: Message
public Message(
Guid id,
string name,
string description,
Color backgroundColor,
IEnumerable<IMessagePart> parts,
EventHandlerCollection eventHandlerCollection = null)
{
name.ThrowIfNull("name");
description.ThrowIfNull("description");
parts.ThrowIfNull("parts");
parts = parts.ToArray();
IMessagePart question = parts.SingleOrDefault(arg => arg is MessageMananger);
if (question != null && parts.Last() != question)
{
throw new ArgumentException("When a MessageQuestion is present, it must be the last part.", "parts");
}
_id = id;
Name = name;
Description = description;
_backgroundColor = backgroundColor;
_parts = parts;
_eventHandlerCollection = eventHandlerCollection;
}
示例4: GetRoutes
public IEnumerable<Routing.Route> GetRoutes(IGuidFactory guidFactory, IUrlResolver urlResolver, IHttpRuntime httpRuntime, string diagnosticsRelativeUrl, IEnumerable<IDiagnosticConfiguration> configurations)
{
guidFactory.ThrowIfNull("guidFactory");
urlResolver.ThrowIfNull("urlResolver");
diagnosticsRelativeUrl.ThrowIfNull("diagnosticsUrl");
configurations.ThrowIfNull("configurations");
string diagnosticsUrl = urlResolver.Absolute(diagnosticsRelativeUrl);
yield return DiagnosticRouteHelper.Instance.GetViewRoute<DiagnosticsView>(
"Diagnostics Home View",
guidFactory,
diagnosticsRelativeUrl,
ResponseResources.Diagnostics,
DiagnosticsViewNamespaces,
httpRuntime,
view =>
{
view.UrlResolver = urlResolver;
AddLinks(view, diagnosticsUrl, configurations);
});
yield return DiagnosticRouteHelper.Instance.GetStylesheetRoute("Diagnostics Common CSS", guidFactory, diagnosticsRelativeUrl + "/css/common", ResponseResources.common, httpRuntime);
yield return DiagnosticRouteHelper.Instance.GetStylesheetRoute("Diagnostics Reset CSS", guidFactory, diagnosticsRelativeUrl + "/css/reset", ResponseResources.reset, httpRuntime);
yield return DiagnosticRouteHelper.Instance.GetJavaScriptRoute("Diagnostics jQuery JS", guidFactory, diagnosticsRelativeUrl + "/js/jquery", ResponseResources.jquery_1_8_2_min, httpRuntime);
foreach (IDiagnosticConfiguration arg in configurations)
{
foreach (Routing.Route route in arg.GetRoutes(guidFactory, urlResolver, httpRuntime, diagnosticsRelativeUrl))
{
yield return route;
}
}
}
示例5: IsSetOfKeysUp
public static bool IsSetOfKeysUp(this KeyboardState keyboardState, IEnumerable<IEnumerable<Keys>> setsOfKeys)
{
keyboardState.ThrowIfNull("keyboardState");
setsOfKeys.ThrowIfNull("setsOfKeys");
return setsOfKeys.Any(arg => AreAllKeysUp(keyboardState, arg));
}
示例6: AreAllKeysUp
public static bool AreAllKeysUp(this KeyboardState keyboardState, IEnumerable<Keys> keys)
{
keyboardState.ThrowIfNull("keyboardState");
keys.ThrowIfNull("keys");
return keys.All(keyboardState.IsKeyUp);
}
示例7: Serialize
public IEnumerable<XElement> Serialize(IEnumerable<IMessagePart> parts)
{
parts.ThrowIfNull("parts");
foreach (IMessagePart part in parts)
{
var messageColor = part as MessageColor;
var messageLineBreak = part as MessageLineBreak;
var messageQuestion = part as MessageQuestion;
var messageText = part as MessageText;
if (messageColor != null)
{
yield return MessageColorSerializer.Instance.Serialize(messageColor);
}
else if (messageLineBreak != null)
{
yield return MessageLineBreakSerializer.Instance.Serialize(messageLineBreak);
}
else if (messageQuestion != null)
{
yield return MessageQuestionSerializer.Instance.Serialize(messageQuestion);
}
else if (messageText != null)
{
yield return MessageTextSerializer.Instance.Serialize(messageText);
}
else
{
throw new ArgumentException(String.Format("Unknown message part type '{0}'.", part.GetType().Name));
}
}
}
示例8: GetResponse
public ResponseResult GetResponse(HttpRequestBase request, IEnumerable<RouteMatchResult> routeMatchResults)
{
request.ThrowIfNull("request");
routeMatchResults.ThrowIfNull("routeMatchResults");
return ResponseResult.ResponseGenerated(Response.NotFound());
}
示例9: Add
public RouteCollection Add(IEnumerable<Route> routes)
{
routes.ThrowIfNull("routes");
foreach (Route route in routes)
{
if (_routeIds.Contains(route.Id))
{
throw new ArgumentException(String.Format("A route with ID {0} has already been added.", route.Id), "routes");
}
if (!_allowDuplicateRouteNames && _routeNames.Contains(route.Name))
{
throw new ArgumentException(String.Format("A route named '{0}' has already been added.", route.Name), "routes");
}
_routes.Add(route);
_routeNames.Add(route.Name);
if (!_allowDuplicateRouteNames)
{
_routeIds.Add(route.Id);
}
}
return this;
}
示例10: DecorateClass
public void DecorateClass(IResource resource,
string className,
CodeTypeDeclaration resourceClass,
ResourceClassGenerator generator,
string serviceClassName,
IEnumerable<IResourceDecorator> allDecorators)
{
resource.ThrowIfNull("resource");
className.ThrowIfNull("className");
resourceClass.ThrowIfNull("resourceClass");
generator.ThrowIfNull("generator");
serviceClassName.ThrowIfNull("serviceClassName");
allDecorators.ThrowIfNull("allDecorators");
if (!resource.IsServiceResource) // Only add subresources of normal resources, not the root resource.
{
// Add all subresources.
foreach (IResource subresource in resource.Resources.Values)
{
// Consider all members in the current class as invalid names.
var forbiddenWords = from CodeTypeMember m in resourceClass.Members select m.Name;
// Generate and add the subresource.
CodeTypeDeclaration decl = GenerateSubresource(
subresource, serviceClassName, allDecorators, generator.RequestGenerator,
generator.ContainerGenerator, forbiddenWords);
resourceClass.Members.Add(decl);
}
}
}
示例11: Add
public RouteCollection Add(IEnumerable<Route> routes)
{
routes.ThrowIfNull("routes");
foreach (Route route in routes)
{
if (_routesById.ContainsKey(route.Id))
{
throw new ArgumentException(String.Format("A route with ID {0} has already been added.", route.Id), "routes");
}
if (!_allowDuplicateRouteNames && _routesByName.ContainsKey(route.Name))
{
throw new ArgumentException(String.Format("A route named '{0}' has already been added.", route.Name), "routes");
}
_routesById.Add(route.Id, route);
List<Route> routeList;
if (!_routesByName.TryGetValue(route.Name, out routeList))
{
routeList = new List<Route>();
_routesByName.Add(route.Name, routeList);
}
routeList.Add(route);
}
return this;
}
示例12: GetResponseAsync
public Task<ResponseResult> GetResponseAsync(HttpContextBase context, IEnumerable<RouteMatchResult> routeMatchResults)
{
context.ThrowIfNull("context");
routeMatchResults.ThrowIfNull("routeMatchResults");
return ResponseResult.ResponseGenerated(new Response().NotFound()).AsCompletedTask();
}
示例13: RouteNotMatched
public static MatchResult RouteNotMatched(IEnumerable<IRestriction> matchedRestrictions, IEnumerable<IRestriction> unmatchedRestrictions)
{
matchedRestrictions.ThrowIfNull("matchedRestrictions");
unmatchedRestrictions.ThrowIfNull("unmatchedRestrictions");
return new MatchResult(MatchResultType.RouteNotMatched, matchedRestrictions, unmatchedRestrictions, null);
}
示例14: RouteMatched
public static MatchResult RouteMatched(IEnumerable<IRestriction> matchedRestrictions, string cacheKey)
{
matchedRestrictions.ThrowIfNull("matchedRestrictions");
cacheKey.ThrowIfNull("cacheKey");
return new MatchResult(MatchResultType.RouteMatched, matchedRestrictions, null, cacheKey);
}
示例15: AspNetHttpHandler
public AspNetHttpHandler(
IRouteCollection routes,
ICache cache,
IEnumerable<IResponseGenerator> responseGenerators,
IEnumerable<IResponseHandler> responseHandlers,
IAntiCsrfCookieManager antiCsrfCookieManager,
IAntiCsrfNonceValidator antiCsrfNonceValidator,
IAntiCsrfResponseGenerator antiCsrfResponseGenerator)
{
routes.ThrowIfNull("routes");
cache.ThrowIfNull("cache");
responseGenerators.ThrowIfNull("responseGenerators");
responseHandlers.ThrowIfNull("responseHandlers");
antiCsrfCookieManager.ThrowIfNull("antiCsrfSessionManager");
antiCsrfNonceValidator.ThrowIfNull("antiCsrfTokenValidator");
antiCsrfResponseGenerator.ThrowIfNull("antiCsrfResponseGenerator");
_routes = routes;
_cache = cache;
_responseGenerators = responseGenerators.ToArray();
_responseHandlers = responseHandlers.ToArray();
_antiCsrfCookieManager = antiCsrfCookieManager;
_antiCsrfNonceValidator = antiCsrfNonceValidator;
_antiCsrfResponseGenerator = antiCsrfResponseGenerator;
}