private static void AddTransactionInterceptorIfIsTransactional(ComponentModel model, TransactionMetaInfoStore store) { TransactionMetaInfo meta = store.GetMetaFor(model.Implementation); if (meta == null) { return; } model.Dependencies.Add(new DependencyModel(null, typeof(TransactionInterceptor), false)); model.Interceptors.AddFirst(new InterceptorReference("eventsourcing.transaction.interceptor")); }
private void Validate(ComponentModel model, TransactionMetaInfoStore store) { if (model.Services.Count() == 0 || model.Services.All(o => o.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> /// Sets the intercepted component's ComponentModel. /// </summary> /// <param name="target">The target's ComponentModel</param> public void SetInterceptedComponentModel(ComponentModel target) { _metaInfo = _infoStore.GetMetaFor(target.Implementation); }