private static void CheckRequestFitsType(Type iBizType, RequestedInOut requestedInOut, ServiceBuilderLookup serviceBaseInfo) { //with async transactions the methods can be a mix of sync or async, so we mask to just check the non-async part var flagsMask = requestedInOut.HasFlag(RequestedInOut.OptionalAsync) ? RequestedInOut.NonAsyncFlagsMask : RequestedInOut.AllFlagsMask; if ((requestedInOut & flagsMask) == (serviceBaseInfo.TypeOfService & flagsMask)) { return; } if (requestedInOut.HasFlag(RequestedInOut.InOrInOut)) { if (!serviceBaseInfo.TypeOfService.HasFlag(RequestedInOut.In)) { throw new InvalidOperationException("The action with interface of " + iBizType.Name + " does not have an input, but you called it with a method that needs an input."); } //otherwise InOrInOut passes this test return; } //Else it is another error throw new InvalidOperationException( string.Format( (string)"Your call of {0} needed '{1}' but the Business class had a different setup of '{2}'", (object)iBizType.Name, (object)requestedInOut, (object)serviceBaseInfo.TypeOfService)); }
//--------------------------------------------------- //private methods private dynamic CreateRequiredServiceInstance(ServiceBuilderLookup serviceBaseInfo, Type iBizType, Type genericInterfacePart, IGenericBizRunnerConfig config) { var genericAgruments = genericInterfacePart.GetGenericArguments().ToList(); genericAgruments.Insert(0, iBizType); return(Activator.CreateInstance( serviceBaseInfo.ServiceHandleType.MakeGenericType(genericAgruments.ToArray()), new object[] { RequiresSaveChanges, config })); }
public BizInfo(Type iBizType, Type extractedActionInterface, ServiceBuilderLookup matchingServiceType) { _iBizType = iBizType; _extractedActionInterface = extractedActionInterface; _matchingServiceType = matchingServiceType; }