public void Configure(IAuthorizationProviderConfig conifg)
    {
        if (conifg != null)
        {
            int hash = conifg.Config.GetHashCode();
            if (!_cache.ContainsKey(hash) || _cache[hash] == null)
            {
                string s = YamlHelpers.Serialize(conifg.Config);
                _cache[hash] = YamlHelpers.Deserialize <WindowsPrincipalProvider>(s);
            }

            Configure(_cache[hash]);

            //if external source declared, merge contents
            if (!string.IsNullOrWhiteSpace(ListSourcePath) && File.Exists(ListSourcePath))
            {
                DateTime lastWriteTime = File.GetLastWriteTimeUtc(ListSourcePath);
                if (!lastWriteTime.Equals(ListSourceLastWriteTime))
                {
                    string s = YamlHelpers.Serialize(conifg.Config);
                    WindowsPrincipalProvider p = YamlHelpers.Deserialize <WindowsPrincipalProvider>(s);
                    Configure(p, lastWriteTime);


                    WindowsPrincipalProvider listSource = YamlHelpers.DeserializeFile <WindowsPrincipalProvider>(ListSourcePath);

                    if (listSource.HasUsers)
                    {
                        EnsureUsersGroups(isUsers: true);

                        if (listSource.Users.HasAllowed)
                        {
                            Users.Allowed.AddRange(listSource.Users.Allowed);
                        }

                        if (listSource.Users.HasDenied)
                        {
                            Users.Denied.AddRange(listSource.Users.Denied);
                        }
                    }
                    if (listSource.HasGroups)
                    {
                        EnsureUsersGroups(isUsers: false);

                        if (listSource.Groups.HasAllowed)
                        {
                            Groups.Allowed.AddRange(listSource.Groups.Allowed);
                        }

                        if (listSource.Groups.HasDenied)
                        {
                            Groups.Denied.AddRange(listSource.Groups.Denied);
                        }
                    }

                    _cache[hash] = this;
                }
            }
        }
    }
    public void Configure(IAuthorizationProviderConfig conifg)
    {
        if (conifg != null)
        {
            int hash = conifg.Config.GetHashCode();
            if (!_cache.ContainsKey(hash) || _cache[hash] == null)
            {
                string s = YamlHelpers.Serialize(conifg.Config);
                _cache[hash] = _inner = YamlHelpers.Deserialize <WindowsUserProvider>(s);
            }
            else
            {
                _inner = _cache[hash];
            }

            //if external source declared, merge contents
            if (!string.IsNullOrWhiteSpace(_inner.ListSourcePath) && File.Exists(_inner.ListSourcePath))
            {
                DateTime lastWriteTime = File.GetLastWriteTimeUtc(_inner.ListSourcePath);
                if (!lastWriteTime.Equals(_inner.ListLastWriteTime))
                {
                    string s = YamlHelpers.Serialize(conifg.Config);
                    _inner = YamlHelpers.Deserialize <WindowsUserProvider>(s);

                    _inner.ListLastWriteTime = lastWriteTime;

                    WindowsUserProvider listSource = YamlHelpers.DeserializeFile <WindowsUserProvider>(_inner.ListSourcePath);

                    if (listSource.HasAllowed)
                    {
                        if (_inner.Allowed == null)
                        {
                            _inner.Allowed = new List <string>();
                        }
                        _inner.Allowed.AddRange(listSource.Allowed);
                    }

                    if (listSource.HasDenied)
                    {
                        if (_inner.Denied == null)
                        {
                            _inner.Denied = new List <string>();
                        }
                        _inner.Denied.AddRange(listSource.Denied);
                    }

                    _cache[hash] = _inner;
                }
            }
        }
    }