/// <summary>
/// Invokes the behavior.
/// </summary>
/// <param name="item">Item on which to invoke the behavior.</param>
/// <returns>Result of the invocation.</returns>
private TReturn InvokeForItem(object item)
{
Contract.Requires(item != null);
if (DynamicResolver.DynamicTryResolve(item, out object resolvedItem))
{
// if a resolvable reference was passed in, that would be considered an
// error because it means that the source graph may contain a reference where
// a definition was expected
throw new InvalidOperationException(string.Format(
"Cannot invoke on resolvable items of type {0}. Resolve the item first.",
item.GetType().FullName));
}
return(this.InvokeForNonILItem(item));
}