private void Validate(ServiceRegistrationInfo model) { Contract.Requires(model.Factory.ImplementationType != null); Contract.Ensures(model.Factory.ImplementationType != null); Maybe <TransactionalClassMetaInfo> meta; List <string> problematicMethods; if (model.ServiceType == null || model.ServiceType.IsInterface || !(meta = _MetaStore.GetMetaFromType(model.Factory.ImplementationType)).HasValue || (problematicMethods = (from method in meta.Value.TransactionalMethods where !method.IsVirtual select method.Name).ToList()).Count == 0) { return; } throw new AutoTxFacilityException( string.Format( CultureInfo.InvariantCulture, "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.Factory.ImplementationType.FullName, string.Join(", ", problematicMethods.ToArray()) ) ); }
void IOnBehalfAware.SetInterceptedComponentModel(ComponentModel target) { Contract.Ensures(_MetaInfo != null); Contract.Assume(target != null && target.Implementation != null); _MetaInfo = _Store.GetMetaFromType(target.Implementation); _State = InterceptorState.Initialized; }
private void SetInterceptedComponentModel(ParentServiceRequestInfo target) { Contract.Ensures(_MetaInfo != null); Contract.Assume(target.ImplementationType != null); _MetaInfo = _Store.GetMetaFromType(target.ImplementationType); _State = InterceptorState.Initialized; }
private void Validate(ComponentModel model) { Contract.Requires(model.Implementation != null); Contract.Ensures(model.Implementation != null); Maybe <TransactionalClassMetaInfo> meta; List <string> problematicMethods; if (model.Services == null || model.Services.All(s => s.IsInterface) || !(meta = _MetaStore.GetMetaFromType(model.Implementation)).HasValue || (problematicMethods = (from method in meta.Value.TransactionalMethods where !method.IsVirtual select method.Name).ToList()).Count == 0) { return; } throw new FacilityException(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(", ", problematicMethods.ToArray()))); }