public static void ResetSourceRestrictions(bool preserveCache = true)
        {
            var tempMethodCache   = new Dictionary <Type, Func <object, string> >();
            var tempMethodSources = new Dictionary <Type, MethodSource>();

            _sourceRestrictionLevel = Defaults.SourceRestriction;

            if (preserveCache && !_methodSources.IsNullOrEmpty() && !_methodCache.IsNullOrEmpty())
            {
                foreach (var typeKey in _methodSources.Where(kvp => kvp.Value.ValidForRestriction(_sourceRestrictionLevel)).Select(kvp => kvp.Key).Intersect(_methodCache.Keys))
                {
                    tempMethodCache[typeKey]   = _methodCache[typeKey];
                    tempMethodSources[typeKey] = _methodSources[typeKey];
                }
            }
            _methodCache   = tempMethodCache;
            _methodSources = tempMethodSources;
        }
 public static bool AllowsSource(this SourceRestrictions restriction, MethodSource source)
 {
     return(source.ValidForRestriction(restriction));
 }
 public static bool ValidForRestriction(this MethodSource source, SourceRestrictions restriction)
 {
     return((MethodSource)((int)restriction & (int)source) == source);
 }
 private static void FullCacheSourceAndSettingsReset()
 {
     _sourceRestrictionLevel = Defaults.SourceRestriction;
     ResetCache(false);
 }