Best JustMockLite code snippet using Telerik.JustMock.Core.Castle.DynamicProxy.ProxyGenerator.CreateClassProxyWithTarget
ProxyGenerator.cs
Source:ProxyGenerator.cs  
...836		/// <remarks>837		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.838		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.839		/// </remarks>840		public TClass CreateClassProxyWithTarget<TClass>(TClass target, params IInterceptor[] interceptors)841			where TClass : class842		{843			return (TClass)CreateClassProxyWithTarget(typeof(TClass),844			                                          Type.EmptyTypes,845			                                          target,846			                                          ProxyGenerationOptions.Default,847			                                          new object[0],848			                                          interceptors);849		}850		/// <summary>851		///   Creates proxy object intercepting calls to virtual members of type <typeparamref name = "TClass" /> on newly created instance of that type with given <paramref852		///    name = "interceptors" />.853		/// </summary>854		/// <typeparam name = "TClass">Type of class which will be proxied.</typeparam>855		/// <param name = "target">The target object, calls to which will be intercepted.</param>856		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>857		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>858		/// <returns>859		///   New object of type <typeparamref name = "TClass" /> proxying calls to virtual members of <typeparamref860		///    name = "TClass" /> type.861		/// </returns>862		/// <exception cref = "ArgumentException">Thrown when given <typeparamref name = "TClass" /> is not a class type.</exception>863		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <typeparamref name = "TClass" />.</exception>864		/// <exception cref = "TargetInvocationException">Thrown when default constructor of type <typeparamref name = "TClass" /> throws an exception.</exception>865		/// <remarks>866		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.867		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.868		/// </remarks>869		public TClass CreateClassProxyWithTarget<TClass>(TClass target, ProxyGenerationOptions options,870		                                                 params IInterceptor[] interceptors) where TClass : class871		{872			return (TClass)CreateClassProxyWithTarget(typeof(TClass),873			                                          Type.EmptyTypes,874			                                          target,875			                                          options,876			                                          new object[0],877			                                          interceptors);878		}879		/// <summary>880		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref881		///    name = "interceptors" />.882		/// </summary>883		/// <param name = "classToProxy">Type of class which will be proxied.</param>884		/// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>885		/// <param name = "target">The target object, calls to which will be intercepted.</param>886		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>887		/// <returns>888		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref889		///    name = "classToProxy" /> and <paramref name = "additionalInterfacesToProxy" /> types.890		/// </returns>891		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>892		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> or any of <paramref893		///    name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>894		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>895		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <paramref name = "classToProxy" />.</exception>896		/// <exception cref = "TargetInvocationException">Thrown when default constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>897		/// <remarks>898		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.899		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.900		/// </remarks>901		public object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target,902		                                         params IInterceptor[] interceptors)903		{904			return CreateClassProxyWithTarget(classToProxy,905			                                  additionalInterfacesToProxy,906			                                  target,907			                                  ProxyGenerationOptions.Default,908			                                  new object[0],909			                                  interceptors);910		}911		/// <summary>912		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref913		///    name = "interceptors" />.914		/// </summary>915		/// <param name = "classToProxy">Type of class which will be proxied.</param>916		/// <param name = "target">The target object, calls to which will be intercepted.</param>917		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>918		/// <param name = "constructorArguments">Arguments of constructor of type <paramref name = "classToProxy" /> which should be used to create a new instance of that type.</param>919		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>920		/// <returns>921		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref922		///    name = "classToProxy" /> type.923		/// </returns>924		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>925		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is a generic type definition.</exception>926		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>927		/// <exception cref = "ArgumentException">Thrown when no constructor exists on type <paramref name = "classToProxy" /> with parameters matching <paramref928		///    name = "constructorArguments" />.</exception>929		/// <exception cref = "TargetInvocationException">Thrown when constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>930		/// <remarks>931		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.932		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.933		/// </remarks>934		public object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerationOptions options,935		                                         object[] constructorArguments, params IInterceptor[] interceptors)936		{937			return CreateClassProxyWithTarget(classToProxy,938			                                  Type.EmptyTypes,939			                                  target,940			                                  options,941			                                  constructorArguments,942			                                  interceptors);943		}944		/// <summary>945		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref946		///    name = "interceptors" />.947		/// </summary>948		/// <param name = "classToProxy">Type of class which will be proxied.</param>949		/// <param name = "target">The target object, calls to which will be intercepted.</param>950		/// <param name = "constructorArguments">Arguments of constructor of type <paramref name = "classToProxy" /> which should be used to create a new instance of that type.</param>951		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>952		/// <returns>953		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref954		///    name = "classToProxy" /> type.955		/// </returns>956		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>957		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is a generic type definition.</exception>958		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>959		/// <exception cref = "ArgumentException">Thrown when no constructor exists on type <paramref name = "classToProxy" /> with parameters matching <paramref960		///    name = "constructorArguments" />.</exception>961		/// <exception cref = "TargetInvocationException">Thrown when constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>962		/// <remarks>963		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.964		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.965		/// </remarks>966		public object CreateClassProxyWithTarget(Type classToProxy, object target, object[] constructorArguments,967		                                         params IInterceptor[] interceptors)968		{969			return CreateClassProxyWithTarget(classToProxy,970			                                  Type.EmptyTypes,971			                                  target,972			                                  ProxyGenerationOptions.Default,973			                                  constructorArguments,974			                                  interceptors);975		}976		/// <summary>977		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref978		///    name = "interceptors" />.979		/// </summary>980		/// <param name = "classToProxy">Type of class which will be proxied.</param>981		/// <param name = "target">The target object, calls to which will be intercepted.</param>982		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>983		/// <returns>984		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref985		///    name = "classToProxy" /> type.986		/// </returns>987		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>988		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is a generic type definition.</exception>989		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>990		/// <exception cref = "ArgumentException">Thrown when no parameterless constructor exists on type <paramref991		///    name = "classToProxy" />.</exception>992		/// <exception cref = "TargetInvocationException">Thrown when constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>993		/// <remarks>994		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.995		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.996		/// </remarks>997		public object CreateClassProxyWithTarget(Type classToProxy, object target, params IInterceptor[] interceptors)998		{999			return CreateClassProxyWithTarget(classToProxy,1000			                                  Type.EmptyTypes,1001			                                  target,1002			                                  ProxyGenerationOptions.Default,1003			                                  new object[0],1004			                                  interceptors);1005		}1006		/// <summary>1007		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref1008		///    name = "interceptors" />.1009		/// </summary>1010		/// <param name = "classToProxy">Type of class which will be proxied.</param>1011		/// <param name = "target">The target object, calls to which will be intercepted.</param>1012		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>1013		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>1014		/// <returns>1015		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref1016		///    name = "classToProxy" /> type.1017		/// </returns>1018		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>1019		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "options" /> object is a null reference (Nothing in Visual Basic).</exception>1020		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is a generic type definition.</exception>1021		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>1022		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <paramref name = "classToProxy" />.</exception>1023		/// <exception cref = "TargetInvocationException">Thrown when default constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>1024		/// <remarks>1025		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.1026		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.1027		/// </remarks>1028		public object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerationOptions options,1029		                                         params IInterceptor[] interceptors)1030		{1031			return CreateClassProxyWithTarget(classToProxy,1032			                                  Type.EmptyTypes,1033			                                  target,1034			                                  options,1035			                                  new object[0],1036			                                  interceptors);1037		}1038		/// <summary>1039		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref1040		///    name = "interceptors" />.1041		/// </summary>1042		/// <param name = "classToProxy">Type of class which will be proxied.</param>1043		/// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>1044		/// <param name = "target">The target object, calls to which will be intercepted.</param>1045		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>1046		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>1047		/// <returns>1048		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref1049		///    name = "classToProxy" /> and <paramref name = "additionalInterfacesToProxy" /> types.1050		/// </returns>1051		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>1052		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "options" /> object is a null reference (Nothing in Visual Basic).</exception>1053		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> or any of <paramref1054		///    name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>1055		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>1056		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <paramref name = "classToProxy" />.</exception>1057		/// <exception cref = "TargetInvocationException">Thrown when default constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>1058		/// <remarks>1059		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.1060		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.1061		/// </remarks>1062		public object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target,1063		                                         ProxyGenerationOptions options, params IInterceptor[] interceptors)1064		{1065			return CreateClassProxyWithTarget(classToProxy,1066			                                  additionalInterfacesToProxy,1067			                                  target,1068			                                  options,1069			                                  new object[0],1070			                                  interceptors);1071		}1072		/// <summary>1073		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref1074		///    name = "interceptors" />.1075		/// </summary>1076		/// <param name = "classToProxy">Type of class which will be proxied.</param>1077		/// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>1078		/// <param name = "target">The target object, calls to which will be intercepted.</param>1079		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>1080		/// <param name = "constructorArguments">Arguments of constructor of type <paramref name = "classToProxy" /> which should be used to create a new instance of that type.</param>1081		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>1082		/// <returns>1083		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref1084		///    name = "classToProxy" /> and <paramref name = "additionalInterfacesToProxy" /> types.1085		/// </returns>1086		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>1087		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "options" /> object is a null reference (Nothing in Visual Basic).</exception>1088		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> or any of <paramref1089		///    name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>1090		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>1091		/// <exception cref = "ArgumentException">Thrown when no constructor exists on type <paramref name = "classToProxy" /> with parameters matching <paramref1092		///    name = "constructorArguments" />.</exception>1093		/// <exception cref = "TargetInvocationException">Thrown when constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>1094		/// <remarks>1095		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.1096		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.1097		/// </remarks>1098		public virtual object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target,1099		                                                 ProxyGenerationOptions options, object[] constructorArguments,1100		                                                 params IInterceptor[] interceptors)1101		{1102			if (classToProxy == null)1103			{1104				throw new ArgumentNullException("classToProxy");1105			}1106			if (options == null)1107			{1108				throw new ArgumentNullException("options");1109			}1110			if (!classToProxy.GetTypeInfo().IsClass)1111			{1112				throw new ArgumentException("'classToProxy' must be a class", "classToProxy");...IProxyGenerator.cs
Source:IProxyGenerator.cs  
...586		/// <remarks>587		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.588		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.589		/// </remarks>590		TClass CreateClassProxyWithTarget<TClass>(TClass target, params IInterceptor[] interceptors)591			where TClass : class;592		/// <summary>593		///   Creates proxy object intercepting calls to virtual members of type <typeparamref name = "TClass" /> on newly created instance of that type with given <paramref594		///    name = "interceptors" />.595		/// </summary>596		/// <typeparam name = "TClass">Type of class which will be proxied.</typeparam>597		/// <param name = "target">The target object, calls to which will be intercepted.</param>598		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>599		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>600		/// <returns>601		///   New object of type <typeparamref name = "TClass" /> proxying calls to virtual members of <typeparamref602		///    name = "TClass" /> type.603		/// </returns>604		/// <exception cref = "ArgumentException">Thrown when given <typeparamref name = "TClass" /> is not a class type.</exception>605		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <typeparamref name = "TClass" />.</exception>606		/// <exception cref = "TargetInvocationException">Thrown when default constructor of type <typeparamref name = "TClass" /> throws an exception.</exception>607		/// <remarks>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		TClass CreateClassProxyWithTarget<TClass>(TClass target, ProxyGenerationOptions options,612		                                          params IInterceptor[] interceptors) where TClass : class;613		/// <summary>614		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref615		///    name = "interceptors" />.616		/// </summary>617		/// <param name = "classToProxy">Type of class which will be proxied.</param>618		/// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>619		/// <param name = "target">The target object, calls to which will be intercepted.</param>620		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>621		/// <returns>622		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref623		///    name = "classToProxy" /> and <paramref name = "additionalInterfacesToProxy" /> types.624		/// </returns>625		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>626		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> or any of <paramref627		///    name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>628		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>629		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <paramref name = "classToProxy" />.</exception>630		/// <exception cref = "TargetInvocationException">Thrown when default constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>631		/// <remarks>632		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.633		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.634		/// </remarks>635		object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target,636		                                  params IInterceptor[] interceptors);637		/// <summary>638		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref639		///    name = "interceptors" />.640		/// </summary>641		/// <param name = "classToProxy">Type of class which will be proxied.</param>642		/// <param name = "target">The target object, calls to which will be intercepted.</param>643		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>644		/// <param name = "constructorArguments">Arguments of constructor of type <paramref name = "classToProxy" /> which should be used to create a new instance of that type.</param>645		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>646		/// <returns>647		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref648		///    name = "classToProxy" /> type.649		/// </returns>650		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>651		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is a generic type definition.</exception>652		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>653		/// <exception cref = "ArgumentException">Thrown when no constructor exists on type <paramref name = "classToProxy" /> with parameters matching <paramref654		///    name = "constructorArguments" />.</exception>655		/// <exception cref = "TargetInvocationException">Thrown when constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>656		/// <remarks>657		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.658		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.659		/// </remarks>660		object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerationOptions options,661		                                  object[] constructorArguments, params IInterceptor[] interceptors);662		/// <summary>663		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref664		///    name = "interceptors" />.665		/// </summary>666		/// <param name = "classToProxy">Type of class which will be proxied.</param>667		/// <param name = "target">The target object, calls to which will be intercepted.</param>668		/// <param name = "constructorArguments">Arguments of constructor of type <paramref name = "classToProxy" /> which should be used to create a new instance of that type.</param>669		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>670		/// <returns>671		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref672		///    name = "classToProxy" /> type.673		/// </returns>674		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>675		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is a generic type definition.</exception>676		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>677		/// <exception cref = "ArgumentException">Thrown when no constructor exists on type <paramref name = "classToProxy" /> with parameters matching <paramref678		///    name = "constructorArguments" />.</exception>679		/// <exception cref = "TargetInvocationException">Thrown when constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>680		/// <remarks>681		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.682		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.683		/// </remarks>684		object CreateClassProxyWithTarget(Type classToProxy, object target, object[] constructorArguments,685		                                  params IInterceptor[] interceptors);686		/// <summary>687		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref688		///    name = "interceptors" />.689		/// </summary>690		/// <param name = "classToProxy">Type of class which will be proxied.</param>691		/// <param name = "target">The target object, calls to which will be intercepted.</param>692		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>693		/// <returns>694		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref695		///    name = "classToProxy" /> type.696		/// </returns>697		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>698		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is a generic type definition.</exception>699		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>700		/// <exception cref = "ArgumentException">Thrown when no parameterless constructor exists on type <paramref701		///    name = "classToProxy" />.</exception>702		/// <exception cref = "TargetInvocationException">Thrown when constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>703		/// <remarks>704		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.705		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.706		/// </remarks>707		object CreateClassProxyWithTarget(Type classToProxy, object target, params IInterceptor[] interceptors);708		/// <summary>709		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref710		///    name = "interceptors" />.711		/// </summary>712		/// <param name = "classToProxy">Type of class which will be proxied.</param>713		/// <param name = "target">The target object, calls to which will be intercepted.</param>714		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>715		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>716		/// <returns>717		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref718		///    name = "classToProxy" /> type.719		/// </returns>720		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>721		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "options" /> object is a null reference (Nothing in Visual Basic).</exception>722		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is a generic type definition.</exception>723		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>724		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <paramref name = "classToProxy" />.</exception>725		/// <exception cref = "TargetInvocationException">Thrown when default constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>726		/// <remarks>727		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.728		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.729		/// </remarks>730		object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerationOptions options,731		                                  params IInterceptor[] interceptors);732		/// <summary>733		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref734		///    name = "interceptors" />.735		/// </summary>736		/// <param name = "classToProxy">Type of class which will be proxied.</param>737		/// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>738		/// <param name = "target">The target object, calls to which will be intercepted.</param>739		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>740		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>741		/// <returns>742		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref743		///    name = "classToProxy" /> and <paramref name = "additionalInterfacesToProxy" /> types.744		/// </returns>745		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>746		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "options" /> object is a null reference (Nothing in Visual Basic).</exception>747		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> or any of <paramref748		///    name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>749		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>750		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <paramref name = "classToProxy" />.</exception>751		/// <exception cref = "TargetInvocationException">Thrown when default constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>752		/// <remarks>753		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.754		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.755		/// </remarks>756		object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target,757		                                  ProxyGenerationOptions options, params IInterceptor[] interceptors);758		/// <summary>759		///   Creates proxy object intercepting calls to virtual members of type <paramref name = "classToProxy" /> on newly created instance of that type with given <paramref760		///    name = "interceptors" />.761		/// </summary>762		/// <param name = "classToProxy">Type of class which will be proxied.</param>763		/// <param name = "additionalInterfacesToProxy">Additional interface types. Calls to their members will be proxied as well.</param>764		/// <param name = "target">The target object, calls to which will be intercepted.</param>765		/// <param name = "options">The proxy generation options used to influence generated proxy type and object.</param>766		/// <param name = "constructorArguments">Arguments of constructor of type <paramref name = "classToProxy" /> which should be used to create a new instance of that type.</param>767		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>768		/// <returns>769		///   New object of type <paramref name = "classToProxy" /> proxying calls to virtual members of <paramref770		///    name = "classToProxy" /> and <paramref name = "additionalInterfacesToProxy" /> types.771		/// </returns>772		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "classToProxy" /> object is a null reference (Nothing in Visual Basic).</exception>773		/// <exception cref = "ArgumentNullException">Thrown when given <paramref name = "options" /> object is a null reference (Nothing in Visual Basic).</exception>774		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> or any of <paramref775		///    name = "additionalInterfacesToProxy" /> is a generic type definition.</exception>776		/// <exception cref = "ArgumentException">Thrown when given <paramref name = "classToProxy" /> is not a class type.</exception>777		/// <exception cref = "ArgumentException">Thrown when no constructor exists on type <paramref name = "classToProxy" /> with parameters matching <paramref778		///    name = "constructorArguments" />.</exception>779		/// <exception cref = "TargetInvocationException">Thrown when constructor of type <paramref name = "classToProxy" /> throws an exception.</exception>780		/// <remarks>781		///   This method uses <see cref = "IProxyBuilder" /> implementation to generate a proxy type.782		///   As such caller should expect any type of exception that given <see cref = "IProxyBuilder" /> implementation may throw.783		/// </remarks>784		object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target,785		                                  ProxyGenerationOptions options, object[] constructorArguments,786		                                  params IInterceptor[] interceptors);787		/// <summary>788		///   Creates proxy object intercepting calls to virtual members of type <typeparamref name = "TClass" /> on newly created instance of that type with given <paramref789		///    name = "interceptors" />.790		/// </summary>791		/// <typeparam name = "TClass">Type of class which will be proxied.</typeparam>792		/// <param name = "interceptors">The interceptors called during the invocation of proxied methods.</param>793		/// <returns>794		///   New object of type <typeparamref name = "TClass" /> proxying calls to virtual members of <typeparamref795		///    name = "TClass" /> type.796		/// </returns>797		/// <exception cref = "ArgumentException">Thrown when given <typeparamref name = "TClass" /> is not a class type.</exception>798		/// <exception cref = "ArgumentException">Thrown when no default constructor exists on type <typeparamref name = "TClass" />.</exception>...CreateClassProxyWithTarget
Using AI Code Generation
1using Telerik.JustMock.Core.Castle.DynamicProxy;2{3    {4        public static void Main(string[] args)5        {6            var proxyGenerator = new ProxyGenerator();7            var proxy = proxyGenerator.CreateClassProxyWithTarget(typeof(MyClass), new MyClass(), new MyInterceptor());8            var result = proxy.MyMethod();9        }10    }11    {12        public void Intercept(IInvocation invocation)13        {14            invocation.Proceed();15        }16    }17    {18        public string MyMethod()19        {20            return "Hello World!";21        }22    }23}24using Telerik.JustMock.Core.Castle.DynamicProxy;25{26    {27        public static void Main(string[] args)28        {CreateClassProxyWithTarget
Using AI Code Generation
1using System;2using Telerik.JustMock;3using Telerik.JustMock.Core.Castle.DynamicProxy;4{5    {6        void Method();7    }8    {9        public void Method()10        {11            Console.WriteLine("Method");12        }13    }14    {15        static void Main(string[] args)16        {17            var proxy = new ProxyGenerator();18            var classProxy = proxy.CreateClassProxyWithTarget<IClass>(new Class(), new ClassInterceptor());19            classProxy.Method();20            Console.ReadLine();21        }22    }23    {24        public void Intercept(IInvocation invocation)25        {26            Console.WriteLine("Before invocation");27            invocation.Proceed();28            Console.WriteLine("After invocation");29        }30    }31}CreateClassProxyWithTarget
Using AI Code Generation
1using System;2using Telerik.JustMock;3using Telerik.JustMock.Core.Castle.DynamicProxy;4{5    {6        void testMethod();7    }8    {9        public void testMethod()10        {11            Console.WriteLine("testMethod");12        }13    }14    {15        public void testMethod()16        {17            Console.WriteLine("testMethod1");18        }19    }20    {21        public static void Main()22        {23            TestClass testClass = new TestClass();24            TestClass1 testClass1 = new TestClass1();25            ProxyGenerator proxyGenerator = new ProxyGenerator();26            ITest proxy = proxyGenerator.CreateClassProxyWithTarget<ITest>(testClass1, testClass);27            proxy.testMethod();28        }29    }30}CreateClassProxyWithTarget
Using AI Code Generation
1using System;2using Telerik.JustMock.Core.Castle.DynamicProxy;3using Telerik.JustMock.Core;4{5    {6        public void Method1()7        {8            ProxyGenerator proxyGenerator = new ProxyGenerator();9            ProxyGenerator proxyGenerator1 = new ProxyGenerator();10            var proxy = proxyGenerator.CreateClassProxyWithTarget(typeof(Class1), new Class1(), new ProxyGenerationOptions(), new object[] { });11        }12    }13}14using System;15using Telerik.JustMock.Core.Castle.DynamicProxy;16using Telerik.JustMock.Core;17{18    {19        public void Method1()20        {21            ProxyGenerator proxyGenerator = new ProxyGenerator();22            ProxyGenerator proxyGenerator1 = new ProxyGenerator();23            var proxy = proxyGenerator.CreateClassProxy(typeof(Class1), new ProxyGenerationOptions(), new object[] { });24        }25    }26}27using System;28using Telerik.JustMock.Core.Castle.DynamicProxy;29using Telerik.JustMock.Core;30{31    {32        public void Method1()33        {34            ProxyGenerator proxyGenerator = new ProxyGenerator();35            ProxyGenerator proxyGenerator1 = new ProxyGenerator();36            var proxy = proxyGenerator.CreateClassProxy(typeof(Class1), new Type[] { typeof(IComparable) }, new ProxyGenerationOptions(), new object[] { });37        }38    }39}40using System;41using Telerik.JustMock.Core.Castle.DynamicProxy;42using Telerik.JustMock.Core;43{44    {45        public void Method1()46        {47            ProxyGenerator proxyGenerator = new ProxyGenerator();48            ProxyGenerator proxyGenerator1 = new ProxyGenerator();49            var proxy = proxyGenerator.CreateClassProxy(typeof(Class1), new Type[] { typeof(IComparable) }, new object[] { });50        }51    }52}CreateClassProxyWithTarget
Using AI Code Generation
1using System;2using Telerik.JustMock;3using Telerik.JustMock.Core.Castle.DynamicProxy;4{5    {6        public static void Main(string[] args)7        {8            var proxyGenerator = new ProxyGenerator();9            var proxy = proxyGenerator.CreateClassProxyWithTarget(typeof(Proxy), new Proxy());10            var proxy1 = proxyGenerator.CreateClassProxyWithTarget(typeof(Proxy), new Proxy(), new ProxyInterceptor());11            var proxy2 = proxyGenerator.CreateClassProxyWithTarget(typeof(Proxy), new Proxy(), new ProxyInterceptor(), new ProxyInterceptor2());12            var proxy3 = proxyGenerator.CreateClassProxyWithTarget(typeof(Proxy), new Proxy(), new ProxyInterceptor(), new ProxyInterceptor2(), new ProxyInterceptor3());13        }14    }15    {16        public virtual void DoSomething()17        {18            Console.WriteLine("Do something");19        }20    }21    {22        public void Intercept(IInvocation invocation)23        {24            Console.WriteLine("ProxyInterceptor");25            invocation.Proceed();26        }27    }28    {29        public void Intercept(IInvocation invocation)30        {31            Console.WriteLine("ProxyInterceptor2");32            invocation.Proceed();33        }34    }35    {36        public void Intercept(IInvocation invocation)37        {38            Console.WriteLine("ProxyInterceptor3");39            invocation.Proceed();40        }41    }42}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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
