/// <summary> /// Validates the type is OK to generate a proxy. /// </summary> /// <param name="model">The model.</param> /// <param name="store">The store.</param> private void Validate(ComponentModel model, TransactionMetaInfoStore store) { if (model.Service == null || model.Service.IsInterface) { return; } TransactionMetaInfo meta = store.GetMetaFor(model.Implementation); if (meta == null) { return; } ArrayList problematicMethods = new ArrayList(); foreach(MethodInfo method in meta.Methods) { if (!method.IsVirtual) { problematicMethods.Add(method.Name); } } if (problematicMethods.Count != 0) { String[] methodNames = (String[]) problematicMethods.ToArray(typeof(String)); String message = String.Format("The class {0} wants to use transaction interception, " + "however the methods must be marked as virtual in order to do so. Please correct " + "the following methods: {1}", model.Implementation.FullName, String.Join(", ", methodNames)); throw new FacilityException(message); } }
/// <summary> /// Associates the transaction interceptor with the ComponentModel. /// </summary> /// <param name="model">The model.</param> /// <param name="store">The meta information store.</param> private static void AddTransactionInterceptorIfIsTransactional(ComponentModel model, TransactionMetaInfoStore store) { TransactionMetaInfo meta = store.GetMetaFor(model.Implementation); if (meta == null) { return; } model.Dependencies.Add( new DependencyModel(DependencyType.Service, null, typeof(TransactionInterceptor), false)); model.Interceptors.AddFirst(new InterceptorReference(typeof(TransactionInterceptor))); }