How to use CreateInterfaceProxyWithoutTarget method of Telerik.JustMock.Core.Castle.DynamicProxy.ProxyGenerator class

Best JustMockLite code snippet using Telerik.JustMock.Core.Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget

ProxyGenerator.cs

Source:ProxyGenerator.cs Github

copy

Full Screen

...607 /// As a result of that also at least one <see cref = "IInterceptor" /> implementation must be provided.608 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.609 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.610 /// </remarks>611 public TInterface CreateInterfaceProxyWithoutTarget<TInterface>(IInterceptor interceptor)612 where TInterface : class613 {614 return (TInterface)CreateInterfaceProxyWithoutTarget(typeof(TInterface), interceptor);615 }616 /// <summary>617 /// Creates proxy object intercepting calls to members of interface <typeparamref name = "TInterface" /> on target object generated at runtime with given <paramref618 /// name = "interceptors" />.619 /// </summary>620 /// <typeparam name = "TInterface">Type of the interface which will be proxied.</typeparam>621 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>622 /// <returns>623 /// Object proxying calls to members of <typeparamref name = "TInterface" /> types on generated target object.624 /// </returns>625 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>626 /// <exception cref = "ArgumentException">Thrown when given <typeparamref name = "TInterface" /> is not an interface type.</exception>627 /// <remarks>628 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see629 /// cref = "IInterceptor" /> implementations.630 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see631 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.632 /// As a result of that also at least one <see cref = "IInterceptor" /> implementation must be provided.633 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.634 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.635 /// </remarks>636 public TInterface CreateInterfaceProxyWithoutTarget<TInterface>(params IInterceptor[] interceptors)637 where TInterface : class638 {639 return (TInterface)CreateInterfaceProxyWithoutTarget(typeof(TInterface), interceptors);640 }641 /// <summary>642 /// Creates proxy object intercepting calls to members of interface <typeparamref name = "TInterface" /> on target object generated at runtime with given <paramref643 /// name = "interceptors" />.644 /// </summary>645 /// <typeparam name = "TInterface">Type of the interface which will be proxied.</typeparam>646 /// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>647 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>648 /// <returns>649 /// Object proxying calls to members of <typeparamref name = "TInterface" /> types on generated target object.650 /// </returns>651 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>652 /// <exception cref = "ArgumentException">Thrown when given <typeparamref name = "TInterface" /> is not an interface type.</exception>653 /// <remarks>654 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see655 /// cref = "IInterceptor" /> implementations.656 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see657 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.658 /// As a result of that also at least one <see cref = "IInterceptor" /> implementation must be provided.659 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.660 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.661 /// </remarks>662 public TInterface CreateInterfaceProxyWithoutTarget<TInterface>(ProxyGenerationOptions options,663 params IInterceptor[] interceptors)664 where TInterface : class665 {666 return (TInterface)CreateInterfaceProxyWithoutTarget(typeof(TInterface), Type.EmptyTypes, options, interceptors);667 }668 /// <summary>669 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref670 /// name = "interceptor" />.671 /// </summary>672 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>673 /// <param name = "interceptor">The interceptors called during the invocation of proxied methods.</param>674 /// <returns>675 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> type on generated target object.676 /// </returns>677 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>678 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptor" /> array is a null reference (Nothing in Visual Basic).</exception>679 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is a generic type definition.</exception>680 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>681 /// <remarks>682 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see683 /// cref = "IInterceptor" /> implementations.684 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see685 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.686 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.687 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.688 /// </remarks>689 public object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, IInterceptor interceptor)690 {691 return CreateInterfaceProxyWithoutTarget(interfaceToProxy, Type.EmptyTypes, ProxyGenerationOptions.Default,692 interceptor);693 }694 /// <summary>695 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref696 /// name = "interceptors" />.697 /// </summary>698 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>699 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>700 /// <returns>701 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> type on generated target object.702 /// </returns>703 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>704 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>705 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is a generic type definition.</exception>706 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>707 /// <remarks>708 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see709 /// cref = "IInterceptor" /> implementations.710 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see711 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.712 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.713 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.714 /// </remarks>715 public object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, params IInterceptor[] interceptors)716 {717 return CreateInterfaceProxyWithoutTarget(interfaceToProxy, Type.EmptyTypes, ProxyGenerationOptions.Default,718 interceptors);719 }720 /// <summary>721 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref722 /// name = "interceptors" />.723 /// </summary>724 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>725 /// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>726 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>727 /// <returns>728 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> and <paramref729 /// name = "additionalInterfacesToProxy" /> types on generated target object.730 /// </returns>731 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>732 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>733 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> or any of <paramref734 /// name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>735 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>736 /// <remarks>737 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see738 /// cref = "IInterceptor" /> implementations.739 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see740 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.741 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.742 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.743 /// </remarks>744 public object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy,745 params IInterceptor[] interceptors)746 {747 return CreateInterfaceProxyWithoutTarget(interfaceToProxy, additionalInterfacesToProxy,748 ProxyGenerationOptions.Default, interceptors);749 }750 /// <summary>751 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref752 /// name = "interceptors" />.753 /// </summary>754 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>755 /// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>756 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>757 /// <returns>758 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> on generated target object.759 /// </returns>760 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>761 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>762 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is a generic type definition.</exception>763 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>764 /// <remarks>765 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see766 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.767 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.768 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.769 /// </remarks>770 public object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, ProxyGenerationOptions options,771 params IInterceptor[] interceptors)772 {773 return CreateInterfaceProxyWithoutTarget(interfaceToProxy, Type.EmptyTypes, options, interceptors);774 }775 /// <summary>776 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref777 /// name = "interceptors" />.778 /// </summary>779 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>780 /// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>781 /// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>782 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>783 /// <returns>784 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> and <paramref785 /// name = "additionalInterfacesToProxy" /> types on generated target object.786 /// </returns>787 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>788 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>789 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> or any of <paramref790 /// name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>791 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>792 /// <remarks>793 /// Since this method uses an empty-shell implementation of <paramref name = "additionalInterfacesToProxy" /> to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see794 /// cref = "IInterceptor" /> implementations.795 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see796 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.797 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.798 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.799 /// </remarks>800 public virtual object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy,801 ProxyGenerationOptions options,802 params IInterceptor[] interceptors)803 {804 if (interfaceToProxy == null)805 {806 throw new ArgumentNullException("interfaceToProxy");807 }808 if (interceptors == null)809 {810 throw new ArgumentNullException("interceptors");811 }812 if (!interfaceToProxy.GetTypeInfo().IsInterface)813 {814 throw new ArgumentException("Specified type is not an interface", "interfaceToProxy");...

Full Screen

Full Screen

IProxyGenerator.cs

Source:IProxyGenerator.cs Github

copy

Full Screen

...400 /// As a result of that also at least one <see cref = "IInterceptor" /> implementation must be provided.401 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.402 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.403 /// </remarks>404 TInterface CreateInterfaceProxyWithoutTarget<TInterface>(IInterceptor interceptor)405 where TInterface : class;406 /// <summary>407 /// Creates proxy object intercepting calls to members of interface <typeparamref name = "TInterface" /> on target object generated at runtime with given <paramref408 /// name = "interceptors" />.409 /// </summary>410 /// <typeparam name = "TInterface">Type of the interface which will be proxied.</typeparam>411 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>412 /// <returns>413 /// Object proxying calls to members of <typeparamref name = "TInterface" /> types on generated target object.414 /// </returns>415 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>416 /// <exception cref = "ArgumentException">Thrown when given <typeparamref name = "TInterface" /> is not an interface type.</exception>417 /// <remarks>418 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see419 /// cref = "IInterceptor" /> implementations.420 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see421 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.422 /// As a result of that also at least one <see cref = "IInterceptor" /> implementation must be provided.423 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.424 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.425 /// </remarks>426 TInterface CreateInterfaceProxyWithoutTarget<TInterface>(params IInterceptor[] interceptors)427 where TInterface : class;428 /// <summary>429 /// Creates proxy object intercepting calls to members of interface <typeparamref name = "TInterface" /> on target object generated at runtime with given <paramref430 /// name = "interceptors" />.431 /// </summary>432 /// <typeparam name = "TInterface">Type of the interface which will be proxied.</typeparam>433 /// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>434 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>435 /// <returns>436 /// Object proxying calls to members of <typeparamref name = "TInterface" /> types on generated target object.437 /// </returns>438 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>439 /// <exception cref = "ArgumentException">Thrown when given <typeparamref name = "TInterface" /> is not an interface type.</exception>440 /// <remarks>441 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see442 /// cref = "IInterceptor" /> implementations.443 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see444 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.445 /// As a result of that also at least one <see cref = "IInterceptor" /> implementation must be provided.446 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.447 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.448 /// </remarks>449 TInterface CreateInterfaceProxyWithoutTarget<TInterface>(ProxyGenerationOptions options,450 params IInterceptor[] interceptors)451 where TInterface : class;452 /// <summary>453 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref454 /// name = "interceptor" />.455 /// </summary>456 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>457 /// <param name = "interceptor">The interceptors called during the invocation of proxied methods.</param>458 /// <returns>459 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> type on generated target object.460 /// </returns>461 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>462 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptor" /> array is a null reference (Nothing in Visual Basic).</exception>463 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is a generic type definition.</exception>464 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>465 /// <remarks>466 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see467 /// cref = "IInterceptor" /> implementations.468 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see469 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.470 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.471 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.472 /// </remarks>473 object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, IInterceptor interceptor);474 /// <summary>475 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref476 /// name = "interceptors" />.477 /// </summary>478 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>479 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>480 /// <returns>481 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> type on generated target object.482 /// </returns>483 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>484 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>485 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is a generic type definition.</exception>486 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>487 /// <remarks>488 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see489 /// cref = "IInterceptor" /> implementations.490 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see491 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.492 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.493 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.494 /// </remarks>495 object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, params IInterceptor[] interceptors);496 /// <summary>497 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref498 /// name = "interceptors" />.499 /// </summary>500 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>501 /// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>502 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>503 /// <returns>504 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> and <paramref505 /// name = "additionalInterfacesToProxy" /> types on generated target object.506 /// </returns>507 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>508 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>509 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> or any of <paramref510 /// name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>511 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>512 /// <remarks>513 /// Since this method uses an empty-shell implementation of interfaces to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see514 /// cref = "IInterceptor" /> implementations.515 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see516 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.517 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.518 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.519 /// </remarks>520 object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy,521 params IInterceptor[] interceptors);522 /// <summary>523 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref524 /// name = "interceptors" />.525 /// </summary>526 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>527 /// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>528 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>529 /// <returns>530 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> on generated target object.531 /// </returns>532 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>533 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>534 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is a generic type definition.</exception>535 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>536 /// <remarks>537 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see538 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.539 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.540 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.541 /// </remarks>542 object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, ProxyGenerationOptions options,543 params IInterceptor[] interceptors);544 /// <summary>545 /// Creates proxy object intercepting calls to members of interface <paramref name = "interfaceToProxy" /> on target object generated at runtime with given <paramref546 /// name = "interceptors" />.547 /// </summary>548 /// <param name = "interfaceToProxy">Type of the interface which will be proxied.</param>549 /// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>550 /// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>551 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>552 /// <returns>553 /// Object proxying calls to members of <paramref name = "interfaceToProxy" /> and <paramref554 /// name = "additionalInterfacesToProxy" /> types on generated target object.555 /// </returns>556 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interfaceToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>557 /// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "interceptors" /> array is a null reference (Nothing in Visual Basic).</exception>558 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> or any of <paramref559 /// name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>560 /// <exception cref = "ArgumentException">Thrown when given <paramref name = "interfaceToProxy" /> is not an interface type.</exception>561 /// <remarks>562 /// Since this method uses an empty-shell implementation of <paramref name = "additionalInterfacesToProxy" /> to proxy generated at runtime, the actual implementation of proxied methods must be provided by given <see563 /// cref = "IInterceptor" /> implementations.564 /// They are responsible for setting return value (and out parameters) on proxied methods. It is also illegal for an interceptor to call <see565 /// cref = "IInvocation.Proceed" />, since there's no actual implementation to proceed with.566 /// This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.567 /// As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.568 /// </remarks>569 object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy,570 ProxyGenerationOptions options,571 params IInterceptor[] interceptors);572 /// <summary>573 /// Creates proxy object intercepting calls to virtual members of type <typeparamref name = "TClass" /> on newly created instance of that type with given <paramref574 /// name = "interceptors" />.575 /// </summary>576 /// <typeparam name = "TClass">Type of class which will be proxied.</typeparam>577 /// <param name = "target">The target object, calls to which will be intercepted.</param>578 /// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>579 /// <returns>580 /// New object of type <typeparamref name = "TClass" /> proxying calls to virtual members of <typeparamref581 /// name = "TClass" /> type.582 /// </returns>583 /// <exception cref = "ArgumentException">Thrown when given <typeparamref name = "TClass" /> is not a class type.</exception>...

Full Screen

Full Screen

DynamicProxyMockFactory.cs

Source:DynamicProxyMockFactory.cs Github

copy

Full Screen

...70 if (settings.Args != null && settings.Args.Length > 0)71 throw new ArgumentException("Do not supply contructor arguments when mocking an interface or delegate.");72 try73 {74 instance = generator.CreateInterfaceProxyWithoutTarget(type, settings.AdditionalMockedInterfaces, options, interceptor);75 }76 catch (TypeLoadException ex)77 {78 proxyFailure = ex;79 }80 catch (GeneratorException ex)81 {82 proxyFailure = ex;83 }84 }85 else86 {87 try88 {...

Full Screen

Full Screen

CreateInterfaceProxyWithoutTarget

Using AI Code Generation

copy

Full Screen

1using Telerik.JustMock.Core.Castle.DynamicProxy;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 string MyProperty { get; set; }10 }11 {12 static void Main(string[] args)13 {14 var proxy = new ProxyGenerator().CreateInterfaceProxyWithoutTarget<IMyInterface>(new MyInterceptor());15 proxy.MyProperty = "Hello world";16 Console.WriteLine(proxy.MyProperty);17 Console.ReadKey();18 }19 }20 {21 public void Intercept(IInvocation invocation)22 {23 if (invocation.Method.Name == "get_MyProperty")24 invocation.ReturnValue = "Hello world";25 }26 }27}28using Telerik.JustMock.Core.Castle.DynamicProxy;29using System;30using System.Collections.Generic;31using System.Linq;32using System.Text;33using System.Threading.Tasks;34{35 {36 string MyProperty { get; set; }37 }38 {39 static void Main(string[] args)40 {41 var proxy = new ProxyGenerator().CreateInterfaceProxyWithoutTarget<IMyInterface>(new MyInterceptor());42 proxy.MyProperty = "Hello world";43 Console.WriteLine(proxy.MyProperty);44 Console.ReadKey();45 }46 }47 {48 public void Intercept(IInvocation invocation)49 {50 if (invocation.Method.Name == "get_MyProperty")51 invocation.ReturnValue = "Hello world";52 }53 }54}

Full Screen

Full Screen

CreateInterfaceProxyWithoutTarget

Using AI Code Generation

copy

Full Screen

1public void CreateInterfaceProxyWithoutTarget()2{3 var proxyGenerator = new Telerik.JustMock.Core.Castle.DynamicProxy.ProxyGenerator();4 var proxy = proxyGenerator.CreateInterfaceProxyWithoutTarget(typeof(IInterface));5 var proxyType = proxy.GetType();6}

Full Screen

Full Screen

CreateInterfaceProxyWithoutTarget

Using AI Code Generation

copy

Full Screen

1using System;2using Telerik.JustMock;3{4 {5 static void Main(string[] args)6 {7 var mock = Mock.Create<I1>();8 var interceptors = new IInterceptor[] { new Interceptor1(), new Interceptor2() };9 var proxy = new Telerik.JustMock.Core.Castle.DynamicProxy.ProxyGenerator().CreateInterfaceProxyWithoutTarget<I1>(interceptors);10 proxy.M1();11 proxy.M2();12 }13 }14 {15 void M1();16 void M2();17 }18 {19 public void Intercept(IInvocation invocation)20 {21 Console.WriteLine("Interceptor1");22 }23 }24 {25 public void Intercept(IInvocation invocation)26 {27 Console.WriteLine("Interceptor2");28 }29 }30}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful