Herald.Common.SuspensionManager.SessionStateForFrame C# (CSharp) Метод

SessionStateForFrame() публичный статический Метод

为与指定的 Frame 相关联的会话状态提供存储。 之前已向 RegisterFrame 注册的框架已自动 保存其会话状态且还原为全局 SessionState 的一部分。 未注册的框架具有 在还原已从导航缓存中丢弃的页面时仍然有用的 导航缓存。
应用程序可能决定依靠 NavigationHelper 管理 特定于页面的状态,而非直接使用框架会话状态。
public static SessionStateForFrame ( Frame frame ) : Object>.Dictionary
frame Windows.UI.Xaml.Controls.Frame 需要会话状态的实例。
Результат Object>.Dictionary
        public static Dictionary<String, Object> SessionStateForFrame(Frame frame)
        {
            var frameState = (Dictionary<String, Object>)frame.GetValue(FrameSessionStateProperty);

            if (frameState == null)
            {
                var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
                if (frameSessionKey != null)
                {
                    // 已注册框架反映相应的会话状态
                    if (!_sessionState.ContainsKey(frameSessionKey))
                    {
                        _sessionState[frameSessionKey] = new Dictionary<String, Object>();
                    }
                    frameState = (Dictionary<String, Object>)_sessionState[frameSessionKey];
                }
                else
                {
                    // 未注册框架具有瞬时状态
                    frameState = new Dictionary<String, Object>();
                }
                frame.SetValue(FrameSessionStateProperty, frameState);
            }
            return frameState;
        }