本文整理汇总了C#中IHandler.Where方法的典型用法代码示例。如果您正苦于以下问题:C# IHandler.Where方法的具体用法?C# IHandler.Where怎么用?C# IHandler.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHandler
的用法示例。
在下文中一共展示了IHandler.Where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectHandlers
public IHandler[] SelectHandlers(Type service, IHandler[] handlers)
{
return handlers
.Where(h => h.ComponentModel.Implementation != typeof(Task4))
.OrderBy(h => h.ComponentModel.Implementation.Name)
.ToArray();
}
示例2: SelectHandler
public IHandler SelectHandler(string key, Type service, IHandler[] handlers)
{
var id = string.Format("{0}:{1}", service.Name, GetHostname());
var selectedHandler = handlers.Where(h => h.ComponentModel.Name == id).FirstOrDefault() ??
GetDefaultHandler(service, handlers);
return selectedHandler;
}
示例3: SelectHandler
public IHandler SelectHandler(string key, Type service, IHandler[] handlers)
{
if (handlers.Length == 0)
return null;
var featureSwitcherHandlers = handlers
.Where(handler => handler.ComponentModel.ExtendedProperties.Contains(ExtendedPropertyName))
.Select(handler => new
{
Handler = handler,
Metadata = handler.ComponentModel.ExtendedProperties[ExtendedPropertyName] as RegistrationMetadata
})
.ToArray();
if (featureSwitcherHandlers.Length == 0)
return null;
if (featureSwitcherHandlers.Length != 2)
throw new ComponentRegistrationException("Incorrect feature switch configuration");
var feature = featureSwitcherHandlers[0].Metadata.Feature;
return feature.Is().Enabled
? featureSwitcherHandlers.FirstOrDefault(handler => handler.Metadata.Enabled)?.Handler
: featureSwitcherHandlers.FirstOrDefault(handler => !handler.Metadata.Enabled)?.Handler;
}
示例4: SelectHandler
public IHandler SelectHandler(string key, Type service, IHandler[] handlers)
{
var handlersForService = handlers.Where(h => h.ComponentModel.Name == key || h.ComponentModel.Services.Any(t => t == typeof(ISessionFactory))).ToArray();
if (handlersForService.Count() > 1)
{
// HACK: The default handler should result in one service, but seems not to be the case. Return the last one of the default ones.
var defaultHandler =
handlersForService.LastOrDefault(
h => h.ComponentModel.ExtendedProperties.Contains(Constants.DefaultComponentForServiceFilter));
return defaultHandler ?? handlersForService.FirstOrDefault();
}
return handlersForService.FirstOrDefault();
}
示例5: SelectHandler
public IHandler SelectHandler(string key, Type service, IHandler[] handlers)
{
try
{
var context = _context.Invoke();
if (context == null) return null;
var httpCookie = context.Request.Cookies[_testname];
if (httpCookie == null) return null;
return handlers.Where(x => x.ComponentModel.Name.Contains(httpCookie.Value)).FirstOrDefault();
}catch(HttpException)
{
return null;
}
}
示例6: SelectHandlers
public IHandler[] SelectHandlers(Type service, IHandler[] handlers)
{
handlersAsked = handlers;
return handlers.Where(filter).ToArray();
}