当前位置: 首页>>代码示例>>C#>>正文


C# PageInfo.SetState方法代码示例

本文整理汇总了C#中System.PageInfo.SetState方法的典型用法代码示例。如果您正苦于以下问题:C# PageInfo.SetState方法的具体用法?C# PageInfo.SetState怎么用?C# PageInfo.SetState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.PageInfo的用法示例。


在下文中一共展示了PageInfo.SetState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Serialization_PersistsState_Struct

        public void Serialization_PersistsState_Struct()
        {
            PageInfo sourceEntry = new PageInfo("Page Name", "Arguments");
            sourceEntry.SetState<StructState>("MyKey", new StructState() { Text = "Text Value", Number = 42 });

            byte[] data = SerializationHelper.SerializeToArray(sourceEntry);
            PageInfo newEntry = SerializationHelper.DeserializeFromArray<PageInfo>(data);

            var state = newEntry.GetState<StructState>("MyKey");
            Assert.Equal("Text Value", state.Text);
            Assert.Equal(42, state.Number);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:12,代码来源:PageInfoFixture.cs

示例2: Serialization_PersistsState_NullClass

        public void Serialization_PersistsState_NullClass()
        {
            PageInfo sourceEntry = new PageInfo("Page Name", "Arguments");
            sourceEntry.SetState<ClassState>("MyKey", null);

            byte[] data = SerializationHelper.SerializeToArray(sourceEntry);
            PageInfo newEntry = SerializationHelper.DeserializeFromArray<PageInfo>(data);

            Assert.Equal(null, newEntry.GetState<ClassState>("MyKey"));
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:10,代码来源:PageInfoFixture.cs

示例3: SetState_RaisesStateChangedEvent

        public void SetState_RaisesStateChangedEvent()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            List<string> stateChangedKeys = new List<string>();
            navigationEntry.StateChanged += (sender, e) => { stateChangedKeys.Add(e.StateKey); };

            navigationEntry.SetState<string>("MyKey", "Test State");

            Assert.Equal(new[] { "MyKey" }, stateChangedKeys);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:11,代码来源:PageInfoFixture.cs

示例4: SetState_Exception_KeyIsEmpty

        public void SetState_Exception_KeyIsEmpty()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            var e = Assert.Throws<ArgumentException>(() => navigationEntry.SetState<string>("", "Test"));

            Assert.Equal("The argument cannot be null or an empty string.\r\nParameter name: key", e.Message);
            Assert.Equal("key", e.ParamName);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:9,代码来源:PageInfoFixture.cs

示例5: TryGetState_Exception_IncorrectType

        public void TryGetState_Exception_IncorrectType()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");
            navigationEntry.SetState<string>("MyKey", "Test State");

            int result;
            var e = Assert.Throws<InvalidCastException>(() => navigationEntry.TryGetState<int>("MyKey", out result));

            Assert.Equal("Specified cast is not valid.", e.Message);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:10,代码来源:PageInfoFixture.cs

示例6: SetState_SameStateKeyOverwritesPreviousValue

        public void SetState_SameStateKeyOverwritesPreviousValue()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<string>("MyKey", "State A");
            navigationEntry.SetState<string>("MyKey", "State B");

            string result;
            bool success = navigationEntry.TryGetState<string>("MyKey", out result);

            Assert.Equal(true, success);
            Assert.Equal("State B", result);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:13,代码来源:PageInfoFixture.cs

示例7: TryGetSetState_Class_StoresNullState

        public void TryGetSetState_Class_StoresNullState()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<ClassState>("MyKey", null);
            ClassState result;
            bool success = navigationEntry.TryGetState<ClassState>("MyKey", out result);

            Assert.Equal(true, success);
            Assert.Equal(null, result);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:11,代码来源:PageInfoFixture.cs

示例8: TryGetSetState_Struct_StoresState

        public void TryGetSetState_Struct_StoresState()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<StructState>("MyKey", new StructState() { Text = "Text Value", Number = 42 });
            StructState result;
            bool success = navigationEntry.TryGetState<StructState>("MyKey", out result);

            Assert.Equal(true, success);
            Assert.Equal("Text Value", result.Text);
            Assert.Equal(42, result.Number);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:12,代码来源:PageInfoFixture.cs

示例9: TryGetSetState_String_StoresState

        public void TryGetSetState_String_StoresState()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<string>("MyKey", "Test State");
            string result;
            bool success = navigationEntry.TryGetState<string>("MyKey", out result);

            Assert.Equal(true, success);
            Assert.Equal("Test State", result);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:11,代码来源:PageInfoFixture.cs

示例10: TryGetSetState_Int_StoresState

        public void TryGetSetState_Int_StoresState()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<int>("MyKey", 42);
            int result;
            bool success = navigationEntry.TryGetState<int>("MyKey", out result);

            Assert.Equal(true, success);
            Assert.Equal(42, result);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:11,代码来源:PageInfoFixture.cs

示例11: GetSetState_Struct_StoresState

        public void GetSetState_Struct_StoresState()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<StructState>("MyKey", new StructState() { Text = "Text Value", Number = 42 });
            var result = navigationEntry.GetState<StructState>("MyKey");

            Assert.Equal("Text Value", result.Text);
            Assert.Equal(42, result.Number);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:10,代码来源:PageInfoFixture.cs

示例12: GetSetState_Class_StoresNullState

        public void GetSetState_Class_StoresNullState()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<ClassState>("MyKey", null);
            var result = navigationEntry.GetState<ClassState>("MyKey");

            Assert.Equal(null, result);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:9,代码来源:PageInfoFixture.cs

示例13: GetSetState_Int_StoresState

        public void GetSetState_Int_StoresState()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<int>("MyKey", 42);
            var result = navigationEntry.GetState<int>("MyKey");

            Assert.Equal(42, result);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:9,代码来源:PageInfoFixture.cs

示例14: GetSetState_String_StoresState

        public void GetSetState_String_StoresState()
        {
            PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");

            navigationEntry.SetState<string>("MyKey", "Test State");
            var result = navigationEntry.GetState<string>("MyKey");

            Assert.Equal("Test State", result);
        }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:9,代码来源:PageInfoFixture.cs

示例15: SaveState

 /// <summary>
 /// Saves any state to be recreated in a future session.
 /// </summary>
 /// <param name="pageInfo">Object to store page state.</param>
 public void SaveState(PageInfo pageInfo)
 {
     if (SelectedItem != null)
         pageInfo.SetState<string>("SelectedItem", SelectedItem.UniqueId);
     else
         pageInfo.SetState<string>("SelectedItem", null);
 }
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:11,代码来源:SplitViewModel.cs


注:本文中的System.PageInfo.SetState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。