public bool TryGetTccTransactionExecutor(string key,
                                                 out CacheExecutorDescriptor matchExcutor)
        {
            if (Entries == null)
            {
                throw new ArgumentNullException(nameof(Entries));
            }

            matchExcutor = null;

            if (Entries.TryGetValue(key, out matchExcutor))
            {
                return(matchExcutor != null);
            }

            return(false);
        }
        private static CacheExecutorDescriptor InitDescriptor(
            CompensableAttribute attr,
            MethodInfo methodInfo,
            TypeInfo implType,
            TypeInfo serviceTypeInfo,
            IList <ParameterDescriptor> parameters)
        {
            var descriptor = new CacheExecutorDescriptor
            {
                Attribute       = attr,
                MethodInfo      = methodInfo,
                ImplTypeInfo    = implType,
                ServiceTypeInfo = serviceTypeInfo,
                Parameters      = parameters
            };

            return(descriptor);
        }
Exemple #3
0
        protected virtual object GetInstance(IServiceProvider provider, CacheExecutorDescriptor descriptor)
        {
            var srvType  = descriptor.ServiceTypeInfo?.AsType();
            var implType = descriptor.ImplTypeInfo.AsType();

            object obj = null;

            if (srvType != null)
            {
                obj = provider.GetServices(srvType).FirstOrDefault(o => o.GetType() == implType);
            }

            if (obj == null)
            {
                obj = ActivatorUtilities.GetServiceOrCreateInstance(provider, implType);
            }

            return(obj);
        }