public InterceptorBindingFailedException( IInterceptHandler handler, Identifiers unknownIdentifiers, Identifiers unresolvedIdentifiers) : base(BuildMessage(handler, unknownIdentifiers, unresolvedIdentifiers)) { Handler = handler; UnknownIdentifiers = unknownIdentifiers; UnresolvedIdentifiers = unresolvedIdentifiers; }
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()); }
/// <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);
/// <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);
public InterceptorBinding(IInterceptHandler handler, IEnumerable <BindingCallback> callbacks) { Handler = handler; Callbacks = new List <BindingCallback>(callbacks).AsReadOnly(); }