示例#1
0
        public static ComputedOptions?FromAttribute(ComputeMethodAttribute?attribute, SwapAttribute?swapAttribute)
        {
            if (attribute == null || !attribute.IsEnabled)
            {
                return(null);
            }
            var swappingOptions = SwappingOptions.FromAttribute(swapAttribute);
            var options         = new ComputedOptions(
                ToTimeSpan(attribute.KeepAliveTime) ?? Default.KeepAliveTime,
                ToTimeSpan(attribute.ErrorAutoInvalidateTime) ?? Default.ErrorAutoInvalidateTime,
                ToTimeSpan(attribute.AutoInvalidateTime) ?? Default.AutoInvalidateTime,
                swappingOptions,
                attribute.RewriteErrors,
                attribute.ComputeMethodDefType);

            return(options.IsDefault() ? Default : options);
        }
        public static ComputedOptions FromAttribute(InterceptedMethodAttribute?attribute, SwapAttribute?cacheAttribute)
        {
            var swappingOptions = SwappingOptions.FromAttribute(cacheAttribute);
            var cma             = attribute as ComputeMethodAttribute;

            if (cma == null && !swappingOptions.IsEnabled)
            {
                return(Default);
            }
            var options = new ComputedOptions(
                ToTimeSpan(cma?.KeepAliveTime) ?? Default.KeepAliveTime,
                ToTimeSpan(cma?.ErrorAutoInvalidateTime) ?? Default.ErrorAutoInvalidateTime,
                ToTimeSpan(cma?.AutoInvalidateTime) ?? Default.AutoInvalidateTime,
                swappingOptions);

            return(options.IsDefault() ? Default : options);
        }
        public static ComputedOptions?FromAttribute(InterceptedMethodAttribute?attribute, SwapAttribute?swapAttribute)
        {
            if (!(attribute is ComputeMethodAttribute cma) || !cma.IsEnabled)
            {
                return(null);
            }
            var swappingOptions = SwappingOptions.FromAttribute(swapAttribute);
            var options         = new ComputedOptions(
                ToTimeSpan(cma.KeepAliveTime) ?? Default.KeepAliveTime,
                ToTimeSpan(cma.ErrorAutoInvalidateTime) ?? Default.ErrorAutoInvalidateTime,
                ToTimeSpan(cma.AutoInvalidateTime) ?? Default.AutoInvalidateTime,
                swappingOptions,
                cma.RewriteErrors,
                cma.InterceptedMethodDescriptorType);

            return(options.IsDefault() ? Default : options);
        }