hammett 2003/09/25 06:24:25
Modified: avalon-net/cscontainer/AvalonContainer DefaultContainer.cs
avalon-net/cscontainer/AvalonContainer/Factory
ComponentFactoryManager.cs
avalon-net/cscontainer/AvalonContainer/Util AssemblyUtil.cs
Log:
Bug solved: We shall look only for exported types in an assembly.
Revision Changes Path
1.3 +1 -1
avalon-sandbox/avalon-net/cscontainer/AvalonContainer/DefaultContainer.cs
Index: DefaultContainer.cs
===================================================================
RCS file:
/home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/DefaultContainer.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultContainer.cs 25 Sep 2003 01:42:34 -0000 1.2
+++ DefaultContainer.cs 25 Sep 2003 13:24:25 -0000 1.3
@@ -297,7 +297,7 @@
foreach(Assembly assembly in assemblies)
{
Pair[] pairs = AssemblyUtil.FindTypesUsingAttribute(
- assembly, typeof( AvalonServiceAttribute ));
+ assembly, typeof( AvalonServiceAttribute ),
true);
foreach(Pair pair in pairs)
{
1.2 +1 -1
avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Factory/ComponentFactoryManager.cs
Index: ComponentFactoryManager.cs
===================================================================
RCS file:
/home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Factory/ComponentFactoryManager.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ComponentFactoryManager.cs 22 Sep 2003 23:49:23 -0000 1.1
+++ ComponentFactoryManager.cs 25 Sep 2003 13:24:25 -0000 1.2
@@ -130,7 +130,7 @@
Assembly currentAssembly = Assembly.GetExecutingAssembly();
return AssemblyUtil.FindTypesUsingAttribute(
- currentAssembly, typeof(LifestyleTargetAttribute));
+ currentAssembly, typeof(LifestyleTargetAttribute),
false);
}
private void InitializePrototype(Pair[] pairs)
1.2 +35 -10
avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Util/AssemblyUtil.cs
Index: AssemblyUtil.cs
===================================================================
RCS file:
/home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Util/AssemblyUtil.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AssemblyUtil.cs 22 Sep 2003 23:49:24 -0000 1.1
+++ AssemblyUtil.cs 25 Sep 2003 13:24:25 -0000 1.2
@@ -60,26 +60,51 @@
{
}
- public static Pair[] FindTypesUsingAttribute(Assembly assembly, Type
attributeType)
+ public static Pair[] FindTypesUsingAttribute(Assembly assembly, Type
attributeType, bool onlyPublicTypes)
{
ArrayList typesFound = new ArrayList();
- Type[] types = assembly.GetTypes();
-
- foreach(Type type in types)
+ try
{
- if (!type.IsClass || type.IsAbstract)
+ AssemblyName[] names =
assembly.GetReferencedAssemblies();
+
+ for(int i=0; i < names.Length; i++)
{
- continue;
+ String dependsOn = names[i].FullName;
+ // TODO: Handle assemblies dependencies
gracefully
}
- object[] attrs = type.GetCustomAttributes(
- attributeType, false);
+ Type[] types = null;
+
+ if (onlyPublicTypes)
+ {
+ types = assembly.GetExportedTypes();
+ }
+ else
+ {
+ types = assembly.GetTypes();
+ }
- if (attrs != null && attrs.Length == 1)
+ foreach(Type type in types)
{
- typesFound.Add(new Pair(type, attrs[0]));
+ if (!type.IsClass || type.IsAbstract)
+ {
+ continue;
+ }
+
+ object[] attrs = type.GetCustomAttributes(
+ attributeType, false);
+
+ if (attrs != null && attrs.Length == 1)
+ {
+ typesFound.Add(new Pair(type,
attrs[0]));
+ }
}
+
+ }
+ catch(Exception e)
+ {
+ throw e;
}
Pair[] pairs = new Pair[typesFound.Count];
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]