From ba6f492b656e28b67634476a28bd65b56d0171d6 Mon Sep 17 00:00:00 2001 From: cneuwirt Date: Sun, 30 Mar 2008 17:02:46 +0000 Subject: [PATCH] Reverted accidental checkin git-svn-id: https://svn.castleproject.org/svn/castle/trunk@4976 73e77b4c-caa6-f847-a29a-24ab75ae54b6 --- .../SynchronizeMetaInfoStore.cs | 90 +++------------------- 1 file changed, 12 insertions(+), 78 deletions(-) diff --git a/Facilities/Synchronize/Castle.Facilities.Synchronize/SynchronizeMetaInfoStore.cs b/Facilities/Synchronize/Castle.Facilities.Synchronize/SynchronizeMetaInfoStore.cs index 6e8dc88ce..c4363d768 100644 --- a/Facilities/Synchronize/Castle.Facilities.Synchronize/SynchronizeMetaInfoStore.cs +++ b/Facilities/Synchronize/Castle.Facilities.Synchronize/SynchronizeMetaInfoStore.cs @@ -17,10 +17,8 @@ namespace Castle.Facilities.Synchronize using System; using System.Collections.Generic; using System.Reflection; - using Castle.Core; using Castle.Core.Configuration; using Castle.MicroKernel; - using Castle.MicroKernel.Proxy; using Castle.MicroKernel.SubSystems.Conversion; /// @@ -51,25 +49,16 @@ namespace Castle.Facilities.Synchronize /// /// Creates the meta-info from the specified type. /// - /// The component model. + /// The implementation type. /// The corresponding meta-info. - public SynchronizeMetaInfo CreateMetaFromModel(ComponentModel model) + public SynchronizeMetaInfo CreateMetaFromType(Type implementation) { - Type implementation = model.Implementation; - SynchronizeAttribute syncAttrib = (SynchronizeAttribute) - model.Implementation.GetCustomAttributes(true)[0]; + implementation.GetCustomAttributes(true)[0]; SynchronizeMetaInfo metaInfo = new SynchronizeMetaInfo(syncAttrib); - if (model.Service.IsInterface) - { - PopulateMetaInfoFromService(metaInfo, model); - } - else - { - PopulateMetaInfoFromClass(metaInfo, implementation); - } + PopulateMetaInfoFromType(metaInfo, implementation); Register(implementation, metaInfo); @@ -77,16 +66,15 @@ namespace Castle.Facilities.Synchronize } /// - /// Populates the meta-info from the class attributes. + /// Populates the meta-info from the attributes. /// /// The meta info. /// The implementation type. - private static void PopulateMetaInfoFromClass(SynchronizeMetaInfo metaInfo, - Type implementation) + private static void PopulateMetaInfoFromType(SynchronizeMetaInfo metaInfo, + Type implementation) { if (implementation == typeof(object) || - implementation == typeof(MarshalByRefObject) || - implementation.IsGenericTypeDefinition) + implementation == typeof(MarshalByRefObject)) { return; } @@ -95,69 +83,15 @@ namespace Castle.Facilities.Synchronize foreach(MethodInfo method in methods) { - PopulateMetaInfoFromMethod(metaInfo, method, null); - } - - PopulateMetaInfoFromClass(metaInfo, implementation.BaseType); - } - - /// - /// Populates the meta-info from the service attributes. - /// - /// The mata info. - /// The component model. - private static void PopulateMetaInfoFromService(SynchronizeMetaInfo metaInfo, - ComponentModel model) - { - Type service = model.Service; - - if (!service.IsGenericTypeDefinition) - { - ProxyOptions proxyOptions = ProxyUtil.ObtainProxyOptions(model, true); + object[] atts = method.GetCustomAttributes(typeof(SynchronizeAttribute), true); - if (proxyOptions.OmitTarget) + if (atts.Length != 0) { - MethodInfo[] methods = service.GetMethods(); - - foreach (MethodInfo method in methods) - { - PopulateMetaInfoFromMethod(metaInfo, method, null); - } - } - else - { - InterfaceMapping mapping = model.Implementation.GetInterfaceMap(service); - MethodInfo[] interfaceMethods = mapping.InterfaceMethods; - MethodInfo[] targetMethods = mapping.TargetMethods; - - for (int i = 0; i < interfaceMethods.Length; ++i) - { - PopulateMetaInfoFromMethod(metaInfo, targetMethods[i], interfaceMethods[i]); - } + metaInfo.Add(method, atts[0] as SynchronizeAttribute); } } - } - /// - /// Populates the meta-info from the method attributes. - /// - /// The meta info. - /// The method. - /// The base method. - private static void PopulateMetaInfoFromMethod(SynchronizeMetaInfo metaInfo, - MethodInfo method, MethodInfo interfaceMethod) - { - object[] atts = method.GetCustomAttributes(typeof(SynchronizeAttribute), true); - - if (atts.Length == 0 && interfaceMethod != null) - { - atts = interfaceMethod.GetCustomAttributes(typeof(SynchronizeAttribute), true); - } - - if (atts.Length != 0) - { - metaInfo.Add(method, atts[0] as SynchronizeAttribute); - } + PopulateMetaInfoFromType(metaInfo, implementation.BaseType); } /// -- 2.11.4.GIT