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 ComputedOptions( TimeSpan keepAliveTime, TimeSpan errorAutoInvalidateTime, TimeSpan autoInvalidateTime, SwappingOptions swappingOptions) { KeepAliveTime = keepAliveTime; ErrorAutoInvalidateTime = errorAutoInvalidateTime; AutoInvalidateTime = autoInvalidateTime; if (ErrorAutoInvalidateTime > autoInvalidateTime) { // It just doesn't make sense to keep it higher ErrorAutoInvalidateTime = autoInvalidateTime; } SwappingOptions = swappingOptions.IsEnabled ? swappingOptions : SwappingOptions.NoSwapping; IsAsyncComputed = swappingOptions.IsEnabled; }
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); }
public ComputedOptions( TimeSpan keepAliveTime, TimeSpan errorAutoInvalidateTime, TimeSpan autoInvalidateTime, SwappingOptions swappingOptions, bool rewriteErrors = false, Type?computeMethodDefType = null) { KeepAliveTime = keepAliveTime; ErrorAutoInvalidateTime = errorAutoInvalidateTime; AutoInvalidateTime = autoInvalidateTime; if (ErrorAutoInvalidateTime > autoInvalidateTime) { // It just doesn't make sense to keep it higher ErrorAutoInvalidateTime = autoInvalidateTime; } SwappingOptions = swappingOptions.IsEnabled ? swappingOptions : SwappingOptions.NoSwapping; RewriteErrors = rewriteErrors; ComputeMethodDefType = computeMethodDefType ?? typeof(ComputeMethodDef); IsAsyncComputed = swappingOptions.IsEnabled; }