User: xtoff
Date: 2009/12/19 03:50 PM
Modified:
/DynamicProxy/trunk/lib/mono-3.5/
Castle.Core.dll, Castle.Core.xml
/DynamicProxy/trunk/lib/net-2.0/
Castle.Core.dll, Castle.Core.xml
/DynamicProxy/trunk/lib/net-3.5/
Castle.Core.dll, Castle.Core.xml
/DynamicProxy/trunk/lib/silverlight-2.0/
Castle.Core.dll, Castle.Core.xml
/DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/
MethodComparerTestCase.cs
/DynamicProxy/trunk/src/Castle.DynamicProxy/
InternalsHelper.cs, InvocationHelper.cs, ModuleScope.cs
/DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
ClassProxyGenerator.cs, InterfaceProxyWithTargetGenerator.cs
Log:
- upgraded references to Castle.Core.dll
- made some members of proxy generator classes virtual for better extensibility
File Changes:
Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/
=======================================================
File [modified]: InternalsHelper.cs
Delta lines: +3 -3
===================================================================
--- DynamicProxy/trunk/src/Castle.DynamicProxy/InvocationHelper.cs
2009-12-19 22:28:37 UTC (rev 6471)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/InvocationHelper.cs
2009-12-19 22:50:24 UTC (rev 6472)
@@ -27,7 +27,7 @@
private static readonly Dictionary<KeyValuePair<MethodInfo,
Type>, MethodInfo> cache =
new Dictionary<KeyValuePair<MethodInfo, Type>,
MethodInfo>();
- private static readonly SlimReaderWriterLock @lock = new
SlimReaderWriterLock();
+ private static readonly Lock @lock = Lock.Create();
public static MethodInfo GetMethodOnObject(object target,
MethodInfo proxiedMethod)
{
@@ -48,7 +48,7 @@
Debug.Assert(proxiedMethod.DeclaringType.IsAssignableFrom(type),
"proxiedMethod.DeclaringType.IsAssignableFrom(type)");
- using (var locker = new UpgradableLock(@lock))
+ using (var locker = @lock.ForReadingUpgradeable())
{
MethodInfo methodOnTarget =
GetFromCache(proxiedMethod, type);
if (methodOnTarget != null)
@@ -62,10 +62,10 @@
{
return methodOnTarget;
}
-
methodOnTarget = ObtainMethod(proxiedMethod,
type);
PutToCache(proxiedMethod, type, methodOnTarget);
return methodOnTarget;
+
}
}
File [modified]: InvocationHelper.cs
Delta lines: +6 -8
===================================================================
--- DynamicProxy/trunk/src/Castle.DynamicProxy/ModuleScope.cs 2009-12-19
22:28:37 UTC (rev 6471)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/ModuleScope.cs 2009-12-19
22:50:24 UTC (rev 6472)
@@ -55,7 +55,7 @@
private readonly Dictionary<CacheKey, Type> typeCache = new
Dictionary<CacheKey, Type>();
// Users of ModuleScope should use this lock when accessing the
cache
- private readonly SlimReaderWriterLock cacheRWLock = new
SlimReaderWriterLock();
+ private readonly Lock cacheLock = Lock.Create();
// Used to lock the module builder creation
private readonly object moduleLocker = new object();
@@ -124,9 +124,9 @@
/// <summary>
/// Users of this <see cref="ModuleScope"/> should use this
lock when accessing the cache.
/// </summary>
- public SlimReaderWriterLock RWLock
+ public Lock Lock
{
- get { return cacheRWLock; }
+ get { return cacheLock; }
}
/// <summary>
@@ -137,10 +137,8 @@
public Type GetFromCache(CacheKey key)
{
Type type;
- if (typeCache.TryGetValue(key, out type))
- return type;
- else
- return null;
+ typeCache.TryGetValue(key, out type);
+ return type;
}
/// <summary>
@@ -456,7 +454,7 @@
{
Dictionary<CacheKey, string> mappings;
- using(new ReadLock(RWLock))
+ using (Lock.ForReading())
{
mappings = new Dictionary<CacheKey, string>();
File [modified]: ModuleScope.cs
Delta lines: +1 -2
===================================================================
--- DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/MethodComparerTestCase.cs
2009-12-19 22:28:37 UTC (rev 6471)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/MethodComparerTestCase.cs
2009-12-19 22:50:24 UTC (rev 6472)
@@ -15,9 +15,8 @@
namespace Castle.DynamicProxy.Tests
{
using System;
- using System.Collections;
using System.Collections.Generic;
- using System.Reflection;
+
using Castle.DynamicProxy.Generators;
using NUnit.Framework;
Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy.Tests/
=============================================================
File [modified]: MethodComparerTestCase.cs
Delta lines: +0 -0
===================================================================
Directory: /DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/
==================================================================
File [modified]: ClassProxyGenerator.cs
Delta lines: +10 -14
===================================================================
---
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithTargetGenerator.cs
2009-12-19 22:28:37 UTC (rev 6471)
+++
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/InterfaceProxyWithTargetGenerator.cs
2009-12-19 22:50:24 UTC (rev 6472)
@@ -21,7 +21,6 @@
using System.Xml.Serialization;
#endif
using Castle.Core.Interceptor;
- using Castle.Core.Internal;
using Castle.DynamicProxy.Generators.Emitters;
using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
using Castle.DynamicProxy.Serialization;
@@ -54,7 +53,7 @@
CacheKey cacheKey = new CacheKey(proxyTargetType,
targetType, interfaces, options);
- using (UpgradableLock locker = new
UpgradableLock(Scope.RWLock))
+ using (var locker = Scope.Lock.ForReadingUpgradeable())
{
Type cacheType = GetFromCache(cacheKey);
if (cacheType != null)
@@ -181,7 +180,7 @@
return generatedType;
}
- protected Type Init(string typeName, IDictionary<Type,
ITypeContributor> typeImplementerMapping, out ClassEmitter emitter, Type
proxyTargetType, out FieldReference interceptorsField)
+ protected virtual Type Init(string typeName, IDictionary<Type,
ITypeContributor> typeImplementerMapping, out ClassEmitter emitter, Type
proxyTargetType, out FieldReference interceptorsField)
{
Type baseType =
ProxyGenerationOptions.BaseTypeForInterfaceProxy;
@@ -225,7 +224,7 @@
get { return false; }
}
- protected IDictionary<Type, ITypeContributor>
GetTypeImplementerMapping(Type[] interfaces, Type proxyTargetType, out
IEnumerable<ITypeContributor> contributors, INamingScope namingScope)
+ protected virtual IDictionary<Type, ITypeContributor>
GetTypeImplementerMapping(Type[] interfaces, Type proxyTargetType, out
IEnumerable<ITypeContributor> contributors, INamingScope namingScope)
{
IDictionary<Type, ITypeContributor>
typeImplementerMapping = new Dictionary<Type, ITypeContributor>();
var mixins = new
MixinContributor(namingScope,AllowChangeTarget);
@@ -285,16 +284,13 @@
HandleExplicitlyPassedProxyTargetAccessor(targetInterfaces,
additionalInterfaces);
}
- var list = new List<ITypeContributor>();
- list.Add(target);
- list.Add(additionalInterfacesContributor);
- //foreach (var mixin in mixins)
- //{
- list.Add(mixins);
- //}
- list.Add(instance);
-
- contributors = list;
+ contributors = new List<ITypeContributor>
+ {
+ target,
+ additionalInterfacesContributor,
+ mixins,
+ instance
+ };
return typeImplementerMapping;
}
File [modified]: InterfaceProxyWithTargetGenerator.cs
Delta lines: +5 -4
===================================================================
--- DynamicProxy/trunk/src/Castle.DynamicProxy/InternalsHelper.cs
2009-12-19 22:28:37 UTC (rev 6471)
+++ DynamicProxy/trunk/src/Castle.DynamicProxy/InternalsHelper.cs
2009-12-19 22:50:24 UTC (rev 6472)
@@ -21,7 +21,7 @@
public class InternalsHelper
{
- private static SlimReaderWriterLock internalsToDynProxyLock =
new SlimReaderWriterLock();
+ private static Lock internalsToDynProxyLock = Lock.Create();
private static IDictionary<Assembly, bool> internalsToDynProxy
= new Dictionary<Assembly, bool>();
/// <summary>
@@ -30,7 +30,7 @@
/// <param name="asm">The assembly to inspect.</param>
public static bool IsInternalToDynamicProxy(Assembly asm)
{
- using (UpgradableLock locker = new
UpgradableLock(internalsToDynProxyLock))
+ using (var locker =
internalsToDynProxyLock.ForReadingUpgradeable())
{
if (internalsToDynProxy.ContainsKey(asm))
{
@@ -45,7 +45,7 @@
}
InternalsVisibleToAttribute[] atts =
(InternalsVisibleToAttribute[])
-
asm.GetCustomAttributes(typeof (InternalsVisibleToAttribute), false);
+
asm.GetCustomAttributes(typeof(InternalsVisibleToAttribute), false);
bool found = false;
@@ -61,6 +61,7 @@
internalsToDynProxy.Add(asm, found);
return found;
+
}
}
@@ -74,7 +75,7 @@
public static bool IsInternal(MethodInfo method)
{
return method.IsAssembly || (method.IsFamilyAndAssembly
- &&
!method.IsFamilyOrAssembly);
+
&& !method.IsFamilyOrAssembly);
}
}
Directory: /DynamicProxy/trunk/lib/mono-3.5/
============================================
File [modified]: Castle.Core.dll
Delta lines: None
None
File [modified]: Castle.Core.xml
Delta lines: +6 -0
===================================================================
--- DynamicProxy/trunk/lib/net-2.0/Castle.Core.xml 2009-12-19 22:28:37 UTC
(rev 6471)
+++ DynamicProxy/trunk/lib/net-2.0/Castle.Core.xml 2009-12-19 22:50:24 UTC
(rev 6472)
@@ -485,6 +485,12 @@
If the index is invalid.
</exception>
</member>
+ <member name="M:Castle.Core.Internal.Lock.Create">
+ <summary>
+ Creates a new lock.
+ </summary>
+ <returns></returns>
+ </member>
<member name="T:Castle.Core.IInitializable">
<summary>
Directory: /DynamicProxy/trunk/lib/net-2.0/
===========================================
File [modified]: Castle.Core.dll
Delta lines: None
None
File [modified]: Castle.Core.xml
Delta lines: +6 -0
===================================================================
--- DynamicProxy/trunk/lib/net-3.5/Castle.Core.xml 2009-12-19 22:28:37 UTC
(rev 6471)
+++ DynamicProxy/trunk/lib/net-3.5/Castle.Core.xml 2009-12-19 22:50:24 UTC
(rev 6472)
@@ -485,6 +485,12 @@
If the index is invalid.
</exception>
</member>
+ <member name="M:Castle.Core.Internal.Lock.Create">
+ <summary>
+ Creates a new lock.
+ </summary>
+ <returns></returns>
+ </member>
<member name="T:Castle.Core.IInitializable">
<summary>
Directory: /DynamicProxy/trunk/lib/net-3.5/
===========================================
File [modified]: Castle.Core.dll
Delta lines: None
None
File [modified]: Castle.Core.xml
Delta lines: +6 -0
===================================================================
--- DynamicProxy/trunk/lib/silverlight-2.0/Castle.Core.xml 2009-12-19
22:28:37 UTC (rev 6471)
+++ DynamicProxy/trunk/lib/silverlight-2.0/Castle.Core.xml 2009-12-19
22:50:24 UTC (rev 6472)
@@ -485,6 +485,12 @@
If the index is invalid.
</exception>
</member>
+ <member name="M:Castle.Core.Internal.Lock.Create">
+ <summary>
+ Creates a new lock.
+ </summary>
+ <returns></returns>
+ </member>
<member name="T:Castle.Core.IInitializable">
<summary>
Directory: /DynamicProxy/trunk/lib/silverlight-2.0/
===================================================
File [modified]: Castle.Core.dll
Delta lines: None
None
File [modified]: Castle.Core.xml
Delta lines: +12 -13
===================================================================
---
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/ClassProxyGenerator.cs
2009-12-19 22:28:37 UTC (rev 6471)
+++
DynamicProxy/trunk/src/Castle.DynamicProxy/Generators/ClassProxyGenerator.cs
2009-12-19 22:50:24 UTC (rev 6472)
@@ -21,7 +21,6 @@
using System.Xml.Serialization;
#endif
using Castle.Core.Interceptor;
- using Castle.Core.Internal;
using Castle.DynamicProxy.Generators.Emitters;
using Castle.DynamicProxy.Generators.Emitters.SimpleAST;
using Contributors;
@@ -59,7 +58,7 @@
CacheKey cacheKey = new CacheKey(targetType,
interfaces, options);
- using (UpgradableLock locker = new
UpgradableLock(Scope.RWLock))
+ using (var locker = Scope.Lock.ForReadingUpgradeable())
{
Type cacheType = GetFromCache(cacheKey);
if (cacheType != null)
@@ -89,12 +88,13 @@
proxyType = GenerateType(name, interfaces,
Scope.NamingScope.SafeSubScope());
AddToCache(cacheKey, proxyType);
+
}
return proxyType;
}
- private Type GenerateType(string newName, Type[] interfaces,
INamingScope namingScope)
+ protected virtual Type GenerateType(string newName, Type[]
interfaces, INamingScope namingScope)
{
IEnumerable<ITypeContributor> contributors;
var implementedInterfaces =
GetTypeImplementerMapping(interfaces, out contributors, namingScope);
@@ -153,7 +153,7 @@
return proxyType;
}
- private IEnumerable<Type> GetTypeImplementerMapping(Type[]
interfaces, out IEnumerable<ITypeContributor> contributors, INamingScope
namingScope)
+ protected virtual IEnumerable<Type>
GetTypeImplementerMapping(Type[] interfaces, out IEnumerable<ITypeContributor>
contributors, INamingScope namingScope)
{
var methodsToSkip = new List<MethodInfo>();
var proxyInstance = new
ClassProxyInstanceContributor(targetType, methodsToSkip, interfaces);
@@ -227,15 +227,14 @@
{
HandleExplicitlyPassedProxyTargetAccessor(targetInterfaces,
additionalInterfaces);
}
- var contributorsList = new List<ITypeContributor>();
- contributorsList.Add(proxyTarget);
- //foreach (var mixin in mixins)
- //{
- contributorsList.Add(mixins);
- //}
- contributorsList.Add(additionalInterfacesContributor);
- contributorsList.Add(proxyInstance);
- contributors = contributorsList;
+
+ contributors = new List<ITypeContributor>
+ {
+ proxyTarget,
+ mixins,
+ additionalInterfacesContributor,
+ proxyInstance
+ };
return typeImplementerMapping.Keys;
}
--
You received this message because you are subscribed to the Google Groups
"Castle Project Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-commits?hl=en.