コード例 #1
0
        public void Save(ControllerContext context, ITempDataProvider provider)
        {
            Precondition.Require(context, () => Error.ArgumentNull("context"));
            Precondition.Require(provider, () => Error.ArgumentNull("provider"));

            string[] keysToKeep   = _initialKeys.Union(_retainedKeys, StringComparer.OrdinalIgnoreCase).ToArray();
            string[] keysToRemove = _data.Keys.Except(keysToKeep, StringComparer.OrdinalIgnoreCase).ToArray();

            foreach (string key in keysToRemove)
            {
                _data.Remove(key);
            }

            provider.Save(context, _data);
        }