本文整理汇总了C#中IHandler类的典型用法代码示例。如果您正苦于以下问题:C# IHandler类的具体用法?C# IHandler怎么用?C# IHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IHandler类属于命名空间,在下文中一共展示了IHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Kernel_ComponentRegistered
private void Kernel_ComponentRegistered(string key, IHandler handler)
{
if (ShouldIntercept(handler.ComponentModel.Implementation))
{
handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(AuditingInterceptor)));
}
}
示例3: HelpMenuHandler
public HelpMenuHandler(IHandler returnTo, string buttonName, GameHandler game = null)
{
background = Main.content.Load<Texture2D>((string)Main.Config[buttonName]["background"]);
returnButton = new MoveButton(returnTo, (JObject)Main.Config[buttonName], true);
this.game = game;
}
示例4: Inspect
public void Inspect(IHandler handler, DependencyModel[] missingDependencies, IKernel kernel)
{
if (handlersChecked.Add(handler) == false)
{
return;
}
Debug.Assert(missingDependencies.Length > 0, "missingDependencies.Length > 0");
var uniqueOverrides = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
message.AppendLine();
message.AppendFormat("'{0}' is waiting for the following dependencies:", handler.ComponentModel.Name);
message.AppendLine();
foreach (var dependency in missingDependencies)
{
if (dependency.ReferencedComponentName != null)
{
// NOTE: that's a workaround for us having dependency twice potentially, once from configuration and once from actual type scan
if (uniqueOverrides.Add(dependency.ReferencedComponentName))
{
InspectServiceOverrideDependency(dependency, kernel);
}
}
else if (dependency.IsPrimitiveTypeDependency)
{
//hardcoding string as it's a most common type that is not value type but you wouldn't want to kave that as a service.
InspectParameterDependency(dependency);
}
else
{
InspectServiceDependency(handler, dependency, kernel);
}
}
}
示例5: SetUp
public void SetUp()
{
_successor = MockRepository.GenerateStub<IHandler>();
_handler = new OptionsHandler(_successor);
_endpointDetails = MockRepository.GenerateStub<IEndpointDetails>();
_credentials = MockRepository.GenerateStub<ICredentials>();
}
示例6: AddResponsiblity
public void AddResponsiblity(object instance, IHandler handler)
{
if (instance == null) throw new ArgumentNullException("instance");
if (handler == null) throw new ArgumentNullException("handler");
references.Add(new DecomissioningResponsibilityReference(instance, handler));
}
示例7: AddAssemblyLevelAttributes
private void AddAssemblyLevelAttributes(List<Attribute> attributes, IHandler handler)
{
attributes.AddRange(
(Attribute[])
handler.ComponentModel.Implementation.Assembly.GetCustomAttributes(typeof(ExceptionHandlerAttribute),
false));
}
示例8: ComponentRegistered
void ComponentRegistered(string key, IHandler handler)
{
if (!(handler.ComponentModel.Implementation.IsPublic || handler.ComponentModel.Implementation.IsNestedPublic))
return;
var matchedAspects = new List<IAspectSelector>();
foreach (var aspect in aspectSelectors)
{
if (aspect.Enabled &&
aspect.IsMatch(handler.ComponentModel.Service))
{
if (matchedAspects.Count == 0)
handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(AspectInterceptor)));
matchedAspects.Add(aspect);
logger.DebugFormat("Adding aspect {0} to service {1}", aspect, handler.ComponentModel.Service);
}
}
// tell the component what aspects are matched.
// give it only the matching aspects so it doesn't need to re-run IsMatch
if (matchedAspects.Count > 0)
{
if (!handler.ComponentModel.ExtendedProperties.Contains(AspectInterceptor.AspectSelectorsExtendedPropertyName))
{
handler.ComponentModel.ExtendedProperties.Add(
AspectInterceptor.AspectSelectorsExtendedPropertyName, matchedAspects);
}
}
}
示例9: WorkerEngine
public WorkerEngine(ISerializer serializer, IHandler handler, string loadbalancerAddress)
{
m_serializer = serializer;
m_loadbalancerAddress = loadbalancerAddress;
m_handler = handler;
m_nextMessageId = 0;
}
示例10: EndPoint
public EndPoint(string method, string pattern, IHandler handler)
{
this.method = method;
this.pattern = pattern;
this.regex = this.ToRegex(pattern);
this.Handler = handler;
}
示例11: TextureBrush
TextureBrush (IHandler handler, Image image, float opacity)
{
this.handler = handler;
this.ControlObject = handler.Create (image, opacity);
this.Image = image;
this.opacity = opacity;
}
示例12: KernelOnComponentRegistered
private static void KernelOnComponentRegistered(string key, IHandler handler)
{
if (UnitOfWorkHelper.IsConventionalUowClass(handler.ComponentModel.Implementation))
{
handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(UnitOfWorkInterceptor)));
}
}
示例13: Register
public virtual void Register(String key, IHandler handler)
{
Type service = handler.Service;
try
{
locker.AcquireWriterLock(Timeout.Infinite);
if (key2Handler.Contains(key))
{
throw new ComponentRegistrationException(
String.Format("There is a component already registered for the given key {0}", key));
}
if (!service2Handler.Contains(service))
{
this[service] = handler;
}
this[key] = handler;
}
finally
{
locker.ReleaseLock();
}
}
示例14: ELM327ListenerEventArgs
/// <summary>
/// Creates a new ELM327ListenerEventArgs object.
/// </summary>
/// <param name="handler">The handler that generated this event.</param>
/// <param name="processedResponse">Processed form of the received response.</param>
/// <param name="isBadResponse">Indicates if any errors were detected in the response.</param>
/// <param name="responseErrors">Description of any errors detected in the response.</param>
public ELM327ListenerEventArgs(IHandler handler, object processedResponse, bool isBadResponse, string responseErrors)
{
_handler = handler;
_processedResponse = processedResponse;
_isBadResponse = isBadResponse;
_responseErrors = responseErrors;
}
示例15: SelectHandlers
public IHandler[] SelectHandlers(Type service, IHandler[] handlers)
{
return handlers
.Where(h => h.ComponentModel.Implementation != typeof(Task4))
.OrderBy(h => h.ComponentModel.Implementation.Name)
.ToArray();
}