How to use InvalidMixinConfigurationException class of Telerik.JustMock.Core.Castle.DynamicProxy package

Best JustMockLite code snippet using Telerik.JustMock.Core.Castle.DynamicProxy.InvalidMixinConfigurationException

Run JustMockLite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

InvalidMixinConfigurationException.cs

Source: InvalidMixinConfigurationException.cs Github

copy
1// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
2// 
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6// 
7//   http://www.apache.org/licenses/LICENSE-2.0
8// 
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15namespace Telerik.JustMock.Core.Castle.DynamicProxy
16{
17	using System;
18#if FEATURE_SERIALIZATION
19	using System.Runtime.Serialization;
20#endif
21
22#if FEATURE_SERIALIZATION
23	[Serializable]
24#endif
25	internal class InvalidMixinConfigurationException : Exception
26	{
27		public InvalidMixinConfigurationException(string message)
28			: base(message)
29		{
30		}
31
32		public InvalidMixinConfigurationException(string message, Exception innerException) : base(message, innerException)
33		{
34		}
35
36#if FEATURE_SERIALIZATION
37		protected InvalidMixinConfigurationException(SerializationInfo info, StreamingContext context) : base(info, context)
38		{
39		}
40#endif
41	}
42}
Full Screen

ProxyGenerationOptions.cs

Source: ProxyGenerationOptions.cs Github

copy
1// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
2// 
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6// 
7//   http://www.apache.org/licenses/LICENSE-2.0
8// 
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15namespace Telerik.JustMock.Core.Castle.DynamicProxy
16{
17	using System;
18	using System.Collections.Generic;
19	using System.Reflection.Emit;
20#if FEATURE_SERIALIZATION
21	using System.Runtime.Serialization;
22#endif
23    using CollectionExtensions = Telerik.JustMock.Core.Castle.Core.Internal.CollectionExtensions;
24#if DOTNET40
25	using System.Security;
26#endif
27
28#if FEATURE_SERIALIZATION
29	[Serializable]
30#endif
31    internal class ProxyGenerationOptions
32#if FEATURE_SERIALIZATION
33		: ISerializable
34#endif
35	{
36		public static readonly ProxyGenerationOptions Default = new ProxyGenerationOptions();
37
38		private List<object> mixins;
39		internal readonly IList<Attribute> attributesToAddToGeneratedTypes = new List<Attribute>();
40		private readonly IList<CustomAttributeInfo> additionalAttributes = new List<CustomAttributeInfo>();
41
42#if FEATURE_SERIALIZATION
43		[NonSerialized]
44#endif
45		private MixinData mixinData; // this is calculated dynamically on proxy type creation
46
47		/// <summary>
48		///   Initializes a new instance of the <see cref = "ProxyGenerationOptions" /> class.
49		/// </summary>
50		/// <param name = "hook">The hook.</param>
51		public ProxyGenerationOptions(IProxyGenerationHook hook)
52		{
53			BaseTypeForInterfaceProxy = typeof(object);
54			Hook = hook;
55		}
56
57		/// <summary>
58		///   Initializes a new instance of the <see cref = "ProxyGenerationOptions" /> class.
59		/// </summary>
60		public ProxyGenerationOptions()
61			: this(new AllMethodsHook())
62		{
63		}
64
65#if FEATURE_SERIALIZATION
66		private ProxyGenerationOptions(SerializationInfo info, StreamingContext context)
67		{
68			Hook = (IProxyGenerationHook)info.GetValue("hook", typeof(IProxyGenerationHook));
69			Selector = (IInterceptorSelector)info.GetValue("selector", typeof(IInterceptorSelector));
70			mixins = (List<object>)info.GetValue("mixins", typeof(List<object>));
71			BaseTypeForInterfaceProxy = Type.GetType(info.GetString("baseTypeForInterfaceProxy.AssemblyQualifiedName"));
72		}
73#endif
74
75		public void Initialize()
76		{
77			if (mixinData == null)
78			{
79				try
80				{
81					mixinData = new MixinData(mixins);
82				}
83				catch (ArgumentException ex)
84				{
85					throw new InvalidMixinConfigurationException(
86						"There is a problem with the mixins added to this ProxyGenerationOptions: " + ex.Message, ex);
87				}
88			}
89		}
90
91#if FEATURE_SERIALIZATION
92#if FEATURE_SECURITY_PERMISSIONS && DOTNET40
93		[SecurityCritical]
94#endif
95		public void GetObjectData(SerializationInfo info, StreamingContext context)
96		{
97			info.AddValue("hook", Hook);
98			info.AddValue("selector", Selector);
99			info.AddValue("mixins", mixins);
100			info.AddValue("baseTypeForInterfaceProxy.AssemblyQualifiedName", BaseTypeForInterfaceProxy.AssemblyQualifiedName);
101		}
102#endif
103
104		public IProxyGenerationHook Hook { get; set; }
105
106		public IInterceptorSelector Selector { get; set; }
107
108		public Type BaseTypeForInterfaceProxy { get; set; }
109
110		public IList<CustomAttributeInfo> AdditionalAttributes
111		{
112			get { return additionalAttributes; }
113		}
114
115		public MixinData MixinData
116		{
117			get
118			{
119				if (mixinData == null)
120				{
121					throw new InvalidOperationException("Call Initialize before accessing the MixinData property.");
122				}
123				return mixinData;
124			}
125		}
126
127		public void AddMixinInstance(object instance)
128		{
129			if (instance == null)
130			{
131				throw new ArgumentNullException("instance");
132			}
133
134			if (mixins == null)
135			{
136				mixins = new List<object>();
137			}
138
139			mixins.Add(instance);
140			mixinData = null;
141		}
142
143		public object[] MixinsAsArray()
144		{
145			if (mixins == null)
146			{
147				return new object[0];
148			}
149
150			return mixins.ToArray();
151		}
152
153		public bool HasMixins
154		{
155			get { return mixins != null && mixins.Count != 0; }
156		}
157
158		public override bool Equals(object obj)
159		{
160			if (ReferenceEquals(this, obj))
161			{
162				return true;
163			}
164
165			var proxyGenerationOptions = obj as ProxyGenerationOptions;
166			if (ReferenceEquals(proxyGenerationOptions, null))
167			{
168				return false;
169			}
170
171			// ensure initialization before accessing MixinData
172			Initialize();
173			proxyGenerationOptions.Initialize();
174
175			if (!Equals(Hook, proxyGenerationOptions.Hook))
176			{
177				return false;
178			}
179			if (!Equals(Selector == null, proxyGenerationOptions.Selector == null))
180			{
181				return false;
182			}
183			if (!Equals(MixinData, proxyGenerationOptions.MixinData))
184			{
185				return false;
186			}
187			if (!Equals(BaseTypeForInterfaceProxy, proxyGenerationOptions.BaseTypeForInterfaceProxy))
188			{
189				return false;
190			}
191			if (!CollectionExtensions.AreEquivalent(AdditionalAttributes, proxyGenerationOptions.AdditionalAttributes))
192			{
193				return false;
194			}
195			return true;
196		}
197
198		public override int GetHashCode()
199		{
200			// ensure initialization before accessing MixinData
201			Initialize();
202
203			var result = Hook != null ? Hook.GetType().GetHashCode() : 0;
204			result = 29*result + (Selector != null ? 1 : 0);
205			result = 29*result + MixinData.GetHashCode();
206			result = 29*result + (BaseTypeForInterfaceProxy != null ? BaseTypeForInterfaceProxy.GetHashCode() : 0);
207			result = 29*result + CollectionExtensions.GetContentsHashCode(AdditionalAttributes);
208			return result;
209		}
210	}
211}
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used methods in InvalidMixinConfigurationException

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)