CSharpTest.Net
GetValue(String,Guid) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Guid) Method

name
defaultValue

Glossary Item Box

Retrieves the named defaultValue from the storage

Syntax

Visual Basic (Declaration) 
Public Overloads Function GetValue( _
   ByVal name As String, _
   ByVal defaultValue As Guid _
) As Guid
C# 
public Guid GetValue( 
   string name,
   Guid defaultValue
)

Parameters

name
defaultValue

Example

Library/Library.Test/TestStorage.cs

C#Copy Code
//Part 1, write
Store.SetValue("bool", ValuesA._bool);
Store.SetValue("byte", ValuesA._byte);
Store.SetValue("char", ValuesA._char);
Store.SetValue("DateTime", ValuesA._DateTime);
Store.SetValue("decimal", ValuesA._decimal);
Store.SetValue("double", ValuesA._double);
Store.SetValue("float", ValuesA._float);
Store.SetValue("Guid", ValuesA._Guid);
Store.SetValue("int", ValuesA._int);
Store.SetValue("long", ValuesA._long);
Store.SetValue("sbyte", ValuesA._sbyte);
Store.SetValue("short", ValuesA._short);
Store.SetValue("string", ValuesA._string);
Store.SetValue("TimeSpan", ValuesA._TimeSpan);
Store.SetValue("uint", ValuesA._uint);
Store.SetValue("ulong", ValuesA._ulong);
Store.SetValue("Uri", ValuesA._Uri);
Store.SetValue("ushort", ValuesA._ushort);
Store.SetValue("Version", ValuesA._Version);
Store.SetValue("object", ValuesA._object.GetType(), ValuesA._object);

//Part 2, read
TestValues values = new TestValues();

Assert.IsTrue(Store.TryGetValue("bool", out values._bool));
Assert.IsTrue(Store.TryGetValue("byte", out values._byte));
Assert.IsTrue(Store.TryGetValue("char", out values._char));
Assert.IsTrue(Store.TryGetValue("DateTime", out values._DateTime));
Assert.IsTrue(Store.TryGetValue("decimal", out values._decimal));
Assert.IsTrue(Store.TryGetValue("double", out values._double));
Assert.IsTrue(Store.TryGetValue("float", out values._float));
Assert.IsTrue(Store.TryGetValue("Guid", out values._Guid));
Assert.IsTrue(Store.TryGetValue("int", out values._int));
Assert.IsTrue(Store.TryGetValue("long", out values._long));
Assert.IsTrue(Store.TryGetValue("sbyte", out values._sbyte));
Assert.IsTrue(Store.TryGetValue("short", out values._short));
Assert.IsTrue(Store.TryGetValue("string", out values._string));
Assert.IsTrue(Store.TryGetValue("TimeSpan", out values._TimeSpan));
Assert.IsTrue(Store.TryGetValue("uint", out values._uint));
Assert.IsTrue(Store.TryGetValue("ulong", out values._ulong));
Assert.IsTrue(Store.TryGetValue("Uri", out values._Uri));
Assert.IsTrue(Store.TryGetValue("ushort", out values._ushort));
Assert.IsTrue(Store.TryGetValue("Version", out values._Version));
Assert.IsTrue(Store.TryGetValue("object", ValuesA._object.GetType(), out values._object));

//Part 3, assert
Assert.AreEqual(ValuesA._bool, values._bool);
Assert.AreEqual(ValuesA._byte, values._byte);
Assert.AreEqual(ValuesA._char, values._char);
Assert.AreEqual(ValuesA._DateTime, values._DateTime);
Assert.AreEqual(ValuesA._decimal, values._decimal);
Assert.AreEqual(ValuesA._double, values._double);
Assert.AreEqual(ValuesA._float, values._float);
Assert.AreEqual(ValuesA._Guid, values._Guid);
Assert.AreEqual(ValuesA._int, values._int);
Assert.AreEqual(ValuesA._long, values._long);
Assert.AreEqual(ValuesA._sbyte, values._sbyte);
Assert.AreEqual(ValuesA._short, values._short);
Assert.AreEqual(ValuesA._string, values._string);
Assert.AreEqual(ValuesA._TimeSpan, values._TimeSpan);
Assert.AreEqual(ValuesA._uint, values._uint);
Assert.AreEqual(ValuesA._ulong, values._ulong);
Assert.AreEqual(ValuesA._Uri, values._Uri);
Assert.AreEqual(ValuesA._ushort, values._ushort);
Assert.AreEqual(ValuesA._Version, values._Version);
Assert.AreEqual(ValuesA._object, values._object);

//Part 4, non-default GetValue
Assert.AreEqual(ValuesA._bool, Store.GetValue("bool", ValuesB._bool));
Assert.AreEqual(ValuesA._byte, Store.GetValue("byte", ValuesB._byte));
Assert.AreEqual(ValuesA._char, Store.GetValue("char", ValuesB._char));
Assert.AreEqual(ValuesA._DateTime, Store.GetValue("DateTime", ValuesB._DateTime));
Assert.AreEqual(ValuesA._decimal, Store.GetValue("decimal", ValuesB._decimal));
Assert.AreEqual(ValuesA._double, Store.GetValue("double", ValuesB._double));
Assert.AreEqual(ValuesA._float, Store.GetValue("float", ValuesB._float));
Assert.AreEqual(ValuesA._Guid, Store.GetValue("Guid", ValuesB._Guid));
Assert.AreEqual(ValuesA._int, Store.GetValue("int", ValuesB._int));
Assert.AreEqual(ValuesA._long, Store.GetValue("long", ValuesB._long));
Assert.AreEqual(ValuesA._sbyte, Store.GetValue("sbyte", ValuesB._sbyte));
Assert.AreEqual(ValuesA._short, Store.GetValue("short", ValuesB._short));
Assert.AreEqual(ValuesA._string, Store.GetValue("string", ValuesB._string));
Assert.AreEqual(ValuesA._TimeSpan, Store.GetValue("TimeSpan", ValuesB._TimeSpan));
Assert.AreEqual(ValuesA._uint, Store.GetValue("uint", ValuesB._uint));
Assert.AreEqual(ValuesA._ulong, Store.GetValue("ulong", ValuesB._ulong));
Assert.AreEqual(ValuesA._Uri, Store.GetValue("Uri", ValuesB._Uri));
Assert.AreEqual(ValuesA._ushort, Store.GetValue("ushort", ValuesB._ushort));
Assert.AreEqual(ValuesA._Version, Store.GetValue("Version", ValuesB._Version));
Assert.AreEqual(ValuesA._object, Store.GetValue("object", ValuesB._object.GetType(), ValuesB._object));
VB.NETCopy Code
'Part 1, write
Store.SetValue("bool", ValuesA._bool)
Store.SetValue("byte", ValuesA._byte)
Store.SetValue("char", ValuesA._char)
Store.SetValue("DateTime", ValuesA._DateTime)
Store.SetValue("decimal", ValuesA._decimal)
Store.SetValue("double", ValuesA._double)
Store.SetValue("float", ValuesA._float)
Store.SetValue("Guid", ValuesA._Guid)
Store.SetValue("int", ValuesA._int)
Store.SetValue("long", ValuesA._long)
Store.SetValue("sbyte", ValuesA._sbyte)
Store.SetValue("short", ValuesA._short)
Store.SetValue("string", ValuesA._string)
Store.SetValue("TimeSpan", ValuesA._TimeSpan)
Store.SetValue("uint", ValuesA._uint)
Store.SetValue("ulong", ValuesA._ulong)
Store.SetValue("Uri", ValuesA._Uri)
Store.SetValue("ushort", ValuesA._ushort)
Store.SetValue("Version", ValuesA._Version)
Store.SetValue("object", ValuesA._object.[GetType](), ValuesA._object)

'Part 2, read
Dim values As New TestValues()

Assert.IsTrue(Store.TryGetValue("bool", values._bool))
Assert.IsTrue(Store.TryGetValue("byte", values._byte))
Assert.IsTrue(Store.TryGetValue("char", values._char))
Assert.IsTrue(Store.TryGetValue("DateTime", values._DateTime))
Assert.IsTrue(Store.TryGetValue("decimal", values._decimal))
Assert.IsTrue(Store.TryGetValue("double", values._double))
Assert.IsTrue(Store.TryGetValue("float", values._float))
Assert.IsTrue(Store.TryGetValue("Guid", values._Guid))
Assert.IsTrue(Store.TryGetValue("int", values._int))
Assert.IsTrue(Store.TryGetValue("long", values._long))
Assert.IsTrue(Store.TryGetValue("sbyte", values._sbyte))
Assert.IsTrue(Store.TryGetValue("short", values._short))
Assert.IsTrue(Store.TryGetValue("string", values._string))
Assert.IsTrue(Store.TryGetValue("TimeSpan", values._TimeSpan))
Assert.IsTrue(Store.TryGetValue("uint", values._uint))
Assert.IsTrue(Store.TryGetValue("ulong", values._ulong))
Assert.IsTrue(Store.TryGetValue("Uri", values._Uri))
Assert.IsTrue(Store.TryGetValue("ushort", values._ushort))
Assert.IsTrue(Store.TryGetValue("Version", values._Version))
Assert.IsTrue(Store.TryGetValue("object", ValuesA._object.[GetType](), values._object))

'Part 3, assert
Assert.AreEqual(ValuesA._bool, values._bool)
Assert.AreEqual(ValuesA._byte, values._byte)
Assert.AreEqual(ValuesA._char, values._char)
Assert.AreEqual(ValuesA._DateTime, values._DateTime)
Assert.AreEqual(ValuesA._decimal, values._decimal)
Assert.AreEqual(ValuesA._double, values._double)
Assert.AreEqual(ValuesA._float, values._float)
Assert.AreEqual(ValuesA._Guid, values._Guid)
Assert.AreEqual(ValuesA._int, values._int)
Assert.AreEqual(ValuesA._long, values._long)
Assert.AreEqual(ValuesA._sbyte, values._sbyte)
Assert.AreEqual(ValuesA._short, values._short)
Assert.AreEqual(ValuesA._string, values._string)
Assert.AreEqual(ValuesA._TimeSpan, values._TimeSpan)
Assert.AreEqual(ValuesA._uint, values._uint)
Assert.AreEqual(ValuesA._ulong, values._ulong)
Assert.AreEqual(ValuesA._Uri, values._Uri)
Assert.AreEqual(ValuesA._ushort, values._ushort)
Assert.AreEqual(ValuesA._Version, values._Version)
Assert.AreEqual(ValuesA._object, values._object)

'Part 4, non-default GetValue
Assert.AreEqual(ValuesA._bool, Store.GetValue("bool", ValuesB._bool))
Assert.AreEqual(ValuesA._byte, Store.GetValue("byte", ValuesB._byte))
Assert.AreEqual(ValuesA._char, Store.GetValue("char", ValuesB._char))
Assert.AreEqual(ValuesA._DateTime, Store.GetValue("DateTime", ValuesB._DateTime))
Assert.AreEqual(ValuesA._decimal, Store.GetValue("decimal", ValuesB._decimal))
Assert.AreEqual(ValuesA._double, Store.GetValue("double", ValuesB._double))
Assert.AreEqual(ValuesA._float, Store.GetValue("float", ValuesB._float))
Assert.AreEqual(ValuesA._Guid, Store.GetValue("Guid", ValuesB._Guid))
Assert.AreEqual(ValuesA._int, Store.GetValue("int", ValuesB._int))
Assert.AreEqual(ValuesA._long, Store.GetValue("long", ValuesB._long))
Assert.AreEqual(ValuesA._sbyte, Store.GetValue("sbyte", ValuesB._sbyte))
Assert.AreEqual(ValuesA._short, Store.GetValue("short", ValuesB._short))
Assert.AreEqual(ValuesA._string, Store.GetValue("string", ValuesB._string))
Assert.AreEqual(ValuesA._TimeSpan, Store.GetValue("TimeSpan", ValuesB._TimeSpan))
Assert.AreEqual(ValuesA._uint, Store.GetValue("uint", ValuesB._uint))
Assert.AreEqual(ValuesA._ulong, Store.GetValue("ulong", ValuesB._ulong))
Assert.AreEqual(ValuesA._Uri, Store.GetValue("Uri", ValuesB._Uri))
Assert.AreEqual(ValuesA._ushort, Store.GetValue("ushort", ValuesB._ushort))
Assert.AreEqual(ValuesA._Version, Store.GetValue("Version", ValuesB._Version))
Assert.AreEqual(ValuesA._object, Store.GetValue("object", ValuesB._object.[GetType](), ValuesB._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys