本文整理汇总了C#中System.PageInfo.GetState方法的典型用法代码示例。如果您正苦于以下问题:C# PageInfo.GetState方法的具体用法?C# PageInfo.GetState怎么用?C# PageInfo.GetState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.PageInfo
的用法示例。
在下文中一共展示了PageInfo.GetState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetState_Exception_KeyIsUndefined
public void GetState_Exception_KeyIsUndefined()
{
PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");
var e = Assert.Throws<KeyNotFoundException>(() => navigationEntry.GetState<string>("Undefined"));
Assert.Equal("The given key was not present in the dictionary.", e.Message);
}
示例2: GetState_Exception_IncorrectType
public void GetState_Exception_IncorrectType()
{
PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");
navigationEntry.SetState<string>("MyKey", "Test State");
var e = Assert.Throws<InvalidCastException>(() => navigationEntry.GetState<int>("MyKey"));
Assert.Equal("Specified cast is not valid.", e.Message);
}
示例3: GetState_Exception_KeyIsEmpty
public void GetState_Exception_KeyIsEmpty()
{
PageInfo navigationEntry = new PageInfo("Page Name", "Arguments");
var e = Assert.Throws<ArgumentException>(() => navigationEntry.GetState<string>(""));
Assert.Equal("The argument cannot be null or an empty string.\r\nParameter name: key", e.Message);
Assert.Equal("key", e.ParamName);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}