예제 #1
0
 public InterceptorBindingFailedException(
     IInterceptHandler handler,
     Identifiers unknownIdentifiers,
     Identifiers unresolvedIdentifiers)
     : base(BuildMessage(handler, unknownIdentifiers, unresolvedIdentifiers))
 {
     Handler               = handler;
     UnknownIdentifiers    = unknownIdentifiers;
     UnresolvedIdentifiers = unresolvedIdentifiers;
 }
예제 #2
0
    private static string BuildMessage(IInterceptHandler handler,
                                       Identifiers unknownIdentifiers,
                                       Identifiers unresolvedIdentifiers)
    {
        var sb = new StringBuilder();

        sb.Append($"Failed to bind to target '{handler.GetType().FullName}'.");

        if (unknownIdentifiers.Count > 0)
        {
            sb.Append(" Unknown identifiers - ");
            sb.Append(unknownIdentifiers.ToString());
            sb.Append('.');
        }

        if (unresolvedIdentifiers.Count > 0)
        {
            sb.Append(" Unresolved identifiers - ");
            sb.Append(unresolvedIdentifiers.ToString());
            sb.Append('.');
        }

        return(sb.ToString());
    }
예제 #3
0
 /// <summary>
 /// Binds the specified target object to the dispatcher.
 /// </summary>
 /// <returns>
 /// <c>true</c> if successfully bound, or <c>false</c> if the target
 /// does not have a receive or intercept attribute on any of its methods.
 /// Throws if any of the required message identifiers are unable to be resolved.
 /// </returns>
 public static bool Bind(this IInterceptor interceptor, IInterceptHandler handler)
 => interceptor.Dispatcher.Bind(handler, interceptor.Client);
예제 #4
0
 /// <summary>
 /// Releases the specified target object from the dispatcher.
 /// </summary>
 /// <returns>Whether the binding was released or not.</returns>
 public static bool Release(this IInterceptor interceptor, IInterceptHandler handler) => interceptor.Dispatcher.Release(handler);
예제 #5
0
 public InterceptorBinding(IInterceptHandler handler, IEnumerable <BindingCallback> callbacks)
 {
     Handler   = handler;
     Callbacks = new List <BindingCallback>(callbacks).AsReadOnly();
 }